discourse/app/models/concerns/reports/time_to_first_response.rb
Jarek Radosz 683ae3f8b9
DEV: Fix assigned but unused variable Prism warnings (#39436)
(Prism is the Ruby LSP parser; those checks might eventually find their
way to rubocop-discourse)

Skipped specs, database migrations, and imports.
2026-04-22 12:42:14 +02:00

34 lines
1,004 B
Ruby
Vendored

# frozen_string_literal: true
module Reports::TimeToFirstResponse
extend ActiveSupport::Concern
class_methods do
def report_time_to_first_response(report)
category_id, include_subcategories = report.add_category_filter
report.icon = "reply"
report.higher_is_better = false
report.y_axis_title = I18n.t("reports.time_to_first_response.yaxis")
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 { |r| report.data << { x: r["date"], y: r["hours"].to_f.round(2) } }
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,
)
end
end
end