FIX: date range was inconsistent for admin dashboard reports
This commit is contained in:
parent
cd66dd1404
commit
f5febe5843
|
@ -161,8 +161,8 @@ Report.reopenClass({
|
|||
}).then(json => {
|
||||
// Add zero values for missing dates
|
||||
if (json.report.data.length > 0) {
|
||||
const startDateFormatted = moment(json.report.start_date).format('YYYY-MM-DD');
|
||||
const endDateFormatted = moment(json.report.end_date).format('YYYY-MM-DD');
|
||||
const startDateFormatted = moment(json.report.start_date).utc().format('YYYY-MM-DD');
|
||||
const endDateFormatted = moment(json.report.end_date).utc().format('YYYY-MM-DD');
|
||||
json.report.data = fillMissingDates(json.report.data, startDateFormatted, endDateFormatted);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ export default Discourse.Route.extend({
|
|||
model: model,
|
||||
categoryId: (model.get('category_id') || 'all'),
|
||||
groupId: model.get('group_id'),
|
||||
startDate: moment(model.get('start_date')).format('YYYY-MM-DD'),
|
||||
endDate: moment(model.get('end_date')).format('YYYY-MM-DD')
|
||||
startDate: moment(model.get('start_date')).utc().format('YYYY-MM-DD'),
|
||||
endDate: moment(model.get('end_date')).utc().format('YYYY-MM-DD')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -142,8 +142,8 @@ module Jobs
|
|||
def report_export
|
||||
return enum_for(:report_export) unless block_given?
|
||||
|
||||
@extra[:start_date] = @extra[:start_date].to_date if @extra[:start_date].is_a?(String)
|
||||
@extra[:end_date] = @extra[:end_date].to_date if @extra[:end_date].is_a?(String)
|
||||
@extra[:start_date] = @extra[:start_date].to_date.beginning_of_day if @extra[:start_date].is_a?(String)
|
||||
@extra[:end_date] = @extra[:end_date].to_date.end_of_day if @extra[:end_date].is_a?(String)
|
||||
@extra[:category_id] = @extra[:category_id].present? ? @extra[:category_id].to_i : nil
|
||||
@extra[:group_id] = @extra[:group_id].present? ? @extra[:group_id].to_i : nil
|
||||
|
||||
|
@ -152,7 +152,7 @@ module Jobs
|
|||
report_hash[row[:x].to_s(:db)] = row[:y].to_s(:db)
|
||||
end
|
||||
|
||||
(@extra[:start_date]..@extra[:end_date]).each do |date|
|
||||
(@extra[:start_date].to_date..@extra[:end_date].to_date).each do |date|
|
||||
yield [date.to_s(:db), report_hash.fetch(date.to_s(:db), 0)]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue