From 313fba92710d39c9c30c2a7f74a3849b2b369bd2 Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Mon, 4 Nov 2019 11:25:48 +1100 Subject: [PATCH] [SDESK-4779] Add subject to publishing based reports --- client/charts/services/ChartConfig.js | 13 +++++++++++++ .../ContentPublishingReportController.js | 2 +- .../PublishingPerformanceReportController.js | 2 +- client/search/services/SearchReport.js | 3 +++ server/analytics/chart_config/__init__.py | 6 ++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/client/charts/services/ChartConfig.js b/client/charts/services/ChartConfig.js index b59f0b56e..ddbb5857b 100644 --- a/client/charts/services/ChartConfig.js +++ b/client/charts/services/ChartConfig.js @@ -544,6 +544,19 @@ export function ChartConfig( ); }) ), + 'subject.qcode': () => ( + metadata.initialize() + .then(() => { + self.setTranslation( + 'subject.qcode', + gettext('Subject'), + _.fromPairs(_.map( + _.get(metadata, 'values.subjectcodes') || [], + (item) => [_.get(item, 'qcode'), _.get(item, 'name')] + )) + ); + }) + ), urgency: () => ( metadata.initialize() .then(() => { diff --git a/client/content_publishing_report/controllers/ContentPublishingReportController.js b/client/content_publishing_report/controllers/ContentPublishingReportController.js index e0870e775..b2ee53364 100644 --- a/client/content_publishing_report/controllers/ContentPublishingReportController.js +++ b/client/content_publishing_report/controllers/ContentPublishingReportController.js @@ -84,7 +84,7 @@ export function ContentPublishingReportController( ); $scope.report_groups = searchReport.filterDataFields( - ['anpa_category.qcode', 'genre.qcode', 'source', 'urgency'] + ['anpa_category.qcode', 'genre.qcode', 'source', 'urgency', 'subject.qcode'] ); $scope.currentParams = { diff --git a/client/publishing_performance_report/controllers/PublishingPerformanceReportController.js b/client/publishing_performance_report/controllers/PublishingPerformanceReportController.js index 9d9186727..6ae00aedc 100644 --- a/client/publishing_performance_report/controllers/PublishingPerformanceReportController.js +++ b/client/publishing_performance_report/controllers/PublishingPerformanceReportController.js @@ -92,7 +92,7 @@ export function PublishingPerformanceReportController( ); $scope.report_groups = searchReport.filterDataFields( - ['task.desk', 'task.user', 'anpa_category.qcode', 'source', 'urgency', 'genre.qcode'] + ['task.desk', 'task.user', 'anpa_category.qcode', 'source', 'urgency', 'genre.qcode', 'subject.qcode'] ); $scope.currentParams = { diff --git a/client/search/services/SearchReport.js b/client/search/services/SearchReport.js index b604b983e..b9436b88d 100644 --- a/client/search/services/SearchReport.js +++ b/client/search/services/SearchReport.js @@ -71,6 +71,9 @@ export function SearchReport(_, config, moment, api, $q, gettext, gettextCatalog }, { qcode: 'task.user', name: gettext('User'), + }, { + qcode: 'subject.qcode', + name: gettext('Subject'), }]; /** diff --git a/server/analytics/chart_config/__init__.py b/server/analytics/chart_config/__init__.py index 1705eaa11..1eb011684 100644 --- a/server/analytics/chart_config/__init__.py +++ b/server/analytics/chart_config/__init__.py @@ -318,6 +318,12 @@ def load_translations_for_field(self, field): 'Genre', get_cv_by_qcode('genre', 'name') ) + elif field == 'subject.qcode': + self._set_translation( + 'subject.qcode', + 'Subject', + get_cv_by_qcode('subjectcodes', 'name') + ) elif field == 'urgency': self._set_translation( 'urgency',