FIX: Show stats of the last 30 days be default for admin reports.
* `1.month.ago + 1.month` uses the calendar month for calculations such that `1.month.ago` from the 30th of March 2017 will give us the 28th of February 2017. Adding one month ahead from 28th February 2017 will be 28th of March 2017.
This commit is contained in:
parent
ee04f90331
commit
a818fa9831
|
@ -7,12 +7,9 @@ class Admin::ReportsController < Admin::AdminController
|
||||||
|
|
||||||
raise Discourse::NotFound unless report_type =~ /^[a-z0-9\_]+$/
|
raise Discourse::NotFound unless report_type =~ /^[a-z0-9\_]+$/
|
||||||
|
|
||||||
start_date = 1.month.ago
|
start_date = params[:start_date].present? ? Time.parse(params[:start_date]) : 30.days.ago
|
||||||
start_date = Time.parse(params[:start_date]) if params[:start_date].present?
|
end_date = params[:end_date].present? ? Time.parse(params[:end_date]) : start_date + 30.days
|
||||||
|
|
||||||
end_date = start_date + 1.month
|
|
||||||
end_date = Time.parse(params[:end_date]) if params[:end_date].present?
|
|
||||||
|
|
||||||
if params.has_key?(:category_id) && params[:category_id].to_i > 0
|
if params.has_key?(:category_id) && params[:category_id].to_i > 0
|
||||||
category_id = params[:category_id].to_i
|
category_id = params[:category_id].to_i
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue