add support for reports of 'time to first response' from a set of users
This commit is contained in:
parent
60bbd81607
commit
30999de3e2
|
@ -114,7 +114,7 @@ class Report
|
|||
|
||||
def self.report_time_to_first_response(report)
|
||||
report.data = []
|
||||
Topic.time_to_first_response_per_day(report.start_date, report.end_date, report.category_id).each do |r|
|
||||
Topic.time_to_first_response_per_day(report.start_date, report.end_date, {category_id: report.category_id}).each do |r|
|
||||
report.data << { x: Date.parse(r["date"]), y: r["hours"].to_f.round(2) }
|
||||
end
|
||||
report.total = Topic.time_to_first_response_total(category_id: report.category_id)
|
||||
|
|
|
@ -911,12 +911,13 @@ class Topic < ActiveRecord::Base
|
|||
builder.where("p.deleted_at IS NULL")
|
||||
builder.where("p.post_number > 1")
|
||||
builder.where("p.user_id != t.user_id")
|
||||
builder.where("p.user_id in (:user_ids)", {user_ids: opts[:user_ids]}) if opts[:user_ids]
|
||||
builder.where("EXTRACT(EPOCH FROM p.created_at - t.created_at) > 0")
|
||||
builder.exec
|
||||
end
|
||||
|
||||
def self.time_to_first_response_per_day(start_date, end_date, category_id=nil)
|
||||
time_to_first_response(TIME_TO_FIRST_RESPONSE_SQL, start_date: start_date, end_date: end_date, category_id: category_id)
|
||||
def self.time_to_first_response_per_day(start_date, end_date, opts={})
|
||||
time_to_first_response(TIME_TO_FIRST_RESPONSE_SQL, opts.merge({start_date: start_date, end_date: end_date}))
|
||||
end
|
||||
|
||||
def self.time_to_first_response_total(opts=nil)
|
||||
|
|
Loading…
Reference in New Issue