diff --git a/app/assets/javascripts/admin/addon/models/report.js b/app/assets/javascripts/admin/addon/models/report.js index 18caf66774a..7a6222ce31b 100644 --- a/app/assets/javascripts/admin/addon/models/report.js +++ b/app/assets/javascripts/admin/addon/models/report.js @@ -569,6 +569,13 @@ Report.reopenClass({ !date.isSame(currentStart) && !date.isBetween(currentStart, currentEnd) ) { + if (model.average) { + const days = currentEnd.diff(currentStart, "day") + 1; // 1 to include start + transformedData[currentIndex].y = parseFloat( + (transformedData[currentIndex].y / days).toFixed(2) + ); + } + currentIndex += 1; currentStart = currentStart.add(1, kind).startOf(isoKind); currentEnd = currentEnd.add(1, kind).endOf(isoKind); diff --git a/app/assets/javascripts/admin/addon/templates/components/admin-report.hbs b/app/assets/javascripts/admin/addon/templates/components/admin-report.hbs index e9fe15e8317..892c802df18 100644 --- a/app/assets/javascripts/admin/addon/templates/components/admin-report.hbs +++ b/app/assets/javascripts/admin/addon/templates/components/admin-report.hbs @@ -131,6 +131,11 @@ {{/if}} {{#if isChartMode}} + {{#if model.average}} + + {{i18n "admin.dashboard.reports.average_chart_label"}} + + {{/if}}
{{#each chartGroupings as |chartGrouping|}} {{d-button diff --git a/app/assets/stylesheets/common/admin/admin_report.scss b/app/assets/stylesheets/common/admin/admin_report.scss index 5a771a9576a..a11c8990c3f 100644 --- a/app/assets/stylesheets/common/admin/admin_report.scss +++ b/app/assets/stylesheets/common/admin/admin_report.scss @@ -119,6 +119,15 @@ } } + .average-chart { + padding: 0.5em; + border: 1px solid var(--highlight-high); + color: var(--highlight-high); + margin-bottom: 1em; + text-align: center; + background: var(--highlight-low); + } + .filters { display: flex; margin-left: 1em; diff --git a/app/models/concerns/reports/time_to_first_response.rb b/app/models/concerns/reports/time_to_first_response.rb index fc26c8856c5..b40f1712c75 100644 --- a/app/models/concerns/reports/time_to_first_response.rb +++ b/app/models/concerns/reports/time_to_first_response.rb @@ -11,6 +11,7 @@ module Reports::TimeToFirstResponse report.icon = 'reply' report.higher_is_better = false report.data = [] + report.average = true Topic.time_to_first_response_per_day(report.start_date, report.end_date, category_id: category_id, include_subcategories: include_subcategories).each do |r| report.data << { x: r['date'], y: r['hours'].to_f.round(2) } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2f733105d7c..8b3f560b3c9 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3895,6 +3895,7 @@ en: trending_search: more: 'Search logs' disabled: 'Trending search report is disabled. Enable log search queries to collect data.' + average_chart_label: Average filters: file_extension: label: File extension