From 79da96db7114d6f403d9c76128573a92846d25bb Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Thu, 7 Sep 2023 13:50:20 +0100 Subject: [PATCH 1/3] Fix report failing with missing elements - when no tags element in content item details. - when no taxon element in content item links. --- lib/reports/future_content_change_statistics_report.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/reports/future_content_change_statistics_report.rb b/lib/reports/future_content_change_statistics_report.rb index 88164e4e8..4551d8c3d 100644 --- a/lib/reports/future_content_change_statistics_report.rb +++ b/lib/reports/future_content_change_statistics_report.rb @@ -59,7 +59,7 @@ def supertypes(content_item) end def tags_from_content_item(content_item) - content_item["details"]["tags"].merge(additional_items(content_item)) + content_item["details"].fetch("tags", {}).merge(additional_items(content_item)) end def links_from_content_item(content_item) @@ -80,6 +80,9 @@ def additional_items(content_item) end def taxon_tree(content_item) + return [] unless content_item["links"].key?("taxons") + return [] unless content_item["links"]["taxons"].any? + [content_item["links"]["taxons"].first["content_id"]] + get_parent_links(content_item["links"]["taxons"].first) end From 66e3261351bfee5d91f7bcfa189d842305e8e842 Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Thu, 7 Sep 2023 13:54:21 +0100 Subject: [PATCH 2/3] Fix draft lacking a default --- lib/tasks/report.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/report.rake b/lib/tasks/report.rake index e042fbfcf..02f759239 100644 --- a/lib/tasks/report.rake +++ b/lib/tasks/report.rake @@ -40,7 +40,7 @@ namespace :report do task :future_content_change_statistics, %i[govuk_path draft] => :environment do |_t, args| puts Reports::FutureContentChangeStatisticsReport.new( args.fetch(:govuk_path), - args.fetch(:draft).downcase == "true", + args.fetch(:draft, "false").downcase == "true", ).call end end From 7e8f6baa2da0cc8e30def566af3db7c37799ad2c Mon Sep 17 00:00:00 2001 From: Keith Lawrence Date: Thu, 7 Sep 2023 15:06:34 +0100 Subject: [PATCH 3/3] Add individual list sizes to notification report --- lib/reports/concerns/notification_stats.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reports/concerns/notification_stats.rb b/lib/reports/concerns/notification_stats.rb index 3f329562a..37c543f6c 100644 --- a/lib/reports/concerns/notification_stats.rb +++ b/lib/reports/concerns/notification_stats.rb @@ -1,6 +1,6 @@ module Reports::Concerns::NotificationStats def list_names_array(lists) - lists.collect(&:title) + lists.map { |l| "#{l.title} (#{l.subscriptions.active.count} active subscribers)" } end def list_stats_array(lists)