FIX: correctly implements average for reports (#13447)

- Also now marks time_to_first_response as an averaged chart
- Averaged charts will now be marked as such in the UI
This commit is contained in:
Joffrey JAFFEUX 2021-06-21 10:35:11 +02:00 committed by GitHub
parent 7901f73597
commit 8c213fa98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -131,6 +131,11 @@
{{/if}}
{{#if isChartMode}}
{{#if model.average}}
<span class="average-chart">
{{i18n "admin.dashboard.reports.average_chart_label"}}
</span>
{{/if}}
<div class="chart-groupings">
{{#each chartGroupings as |chartGrouping|}}
{{d-button

View File

@ -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;

View File

@ -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) }

View File

@ -3895,6 +3895,7 @@ en:
trending_search:
more: '<a href="%{basePath}/admin/logs/search_logs">Search logs</a>'
disabled: 'Trending search report is disabled. Enable <a href="%{basePath}/admin/site_settings/category/all_results?filter=log%20search%20queries">log search queries</a> to collect data.'
average_chart_label: Average
filters:
file_extension:
label: File extension