2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-26 18:17:10 +08:00
|
|
|
Report.add_report('time_to_first_response') do |report|
|
|
|
|
category_filter = report.filters.dig(:category)
|
2020-04-22 16:52:50 +08:00
|
|
|
category_id, include_subcategories = report.add_category_filter
|
2019-04-26 18:17:10 +08:00
|
|
|
|
2019-03-29 17:54:56 +08:00
|
|
|
report.icon = 'reply'
|
|
|
|
report.higher_is_better = false
|
|
|
|
report.data = []
|
2019-04-26 18:17:10 +08:00
|
|
|
|
2020-04-22 16:52:50 +08:00
|
|
|
Topic.time_to_first_response_per_day(report.start_date, report.end_date, category_id: category_id, include_subcategories: include_subcategories).each do |r|
|
2019-04-26 18:17:10 +08:00
|
|
|
report.data << { x: r['date'], y: r['hours'].to_f.round(2) }
|
2019-03-29 17:54:56 +08:00
|
|
|
end
|
2019-04-26 18:17:10 +08:00
|
|
|
|
2020-04-22 16:52:50 +08:00
|
|
|
report.total = Topic.time_to_first_response_total(category_id: category_id, include_subcategories: include_subcategories)
|
2019-04-26 18:17:10 +08:00
|
|
|
|
2020-04-22 16:52:50 +08:00
|
|
|
report.prev30Days = Topic.time_to_first_response_total(start_date: report.start_date - 30.days, end_date: report.start_date, category_id: category_id, include_subcategories: include_subcategories)
|
2019-03-29 17:54:56 +08:00
|
|
|
end
|