mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 19:38:24 +00:00
- remove inactive user report and replace with posts - clean up internals so grouping by week happens on client - when switching periods old report was not destroyed leading to bugs - calculate trend based on previous interval ... not previous 30 days - show percentages for mau/dau - be more careful about utc date usage - show uniqu and click through rate on search panel - publish key of report with report so we only load the correct one - subscribe earlier in channel in case of concurrency issues
27 lines
913 B
Ruby
27 lines
913 B
Ruby
require_dependency 'report'
|
|
|
|
module Jobs
|
|
class RetrieveReport < Jobs::Base
|
|
sidekiq_options retry: false
|
|
|
|
def execute(args)
|
|
raise Discourse::InvalidParameters.new(:report_type) if !args["report_type"]
|
|
|
|
type = args.delete("report_type")
|
|
report = Report.new(type)
|
|
report.start_date = args["start_date"].to_date if args["start_date"]
|
|
report.end_date = args["end_date"].to_date if args["end_date"]
|
|
report.category_id = args["category_id"] if args["category_id"]
|
|
report.group_id = args["group_id"] if args["group_id"]
|
|
report.facets = args["facets"].map(&:to_sym) if args["facets"]
|
|
|
|
Report.send("report_#{type}", report)
|
|
|
|
json = report.as_json
|
|
Discourse.cache.write(Report.cache_key(report), json, force: true, expires_in: 30.minutes)
|
|
|
|
MessageBus.publish("/admin/reports/#{type}", json, user_ids: User.staff.pluck(:id))
|
|
end
|
|
end
|
|
end
|