avoid async report pattern and replace with simpler hijack

This commit is contained in:
Sam
2018-05-16 16:05:03 +10:00
parent 3864091f2d
commit 21e0b7c818
7 changed files with 51 additions and 128 deletions

View File

@ -32,18 +32,36 @@ class Admin::ReportsController < Admin::AdminController
limit = params[:limit].to_i
end
report = Report.find(report_type,
start_date: start_date,
end_date: end_date,
category_id: category_id,
group_id: group_id,
facets: facets,
limit: limit,
async: params[:async])
args = {
start_date: start_date,
end_date: end_date,
category_id: category_id,
group_id: group_id,
facets: facets,
limit: limit
}
raise Discourse::NotFound if report.blank?
report = nil
if (params[:cache])
report = Report.find_cached(report_type, args)
end
if report
return render_json_dump(report: report)
end
hijack do
report = Report.find(report_type, args)
raise Discourse::NotFound if report.blank?
if (params[:cache])
Report.cache(report, 35.minutes)
end
render_json_dump(report: report)
end
render_json_dump(report: report)
end
end