mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: application request numbers for prev 30 day period was for current 30 day period minus today, not previous 30 days
This commit is contained in:
parent
5c8302c789
commit
8c84e60df6
2 changed files with 9 additions and 5 deletions
|
@ -63,11 +63,12 @@ class Report
|
|||
ApplicationRequest.where(req_type: ApplicationRequest.req_types[filter])
|
||||
end
|
||||
|
||||
filtered_results = data.where('date >= ? AND date <= ?', report.start_date.to_date, report.end_date.to_date)
|
||||
filtered_results = filtered_results.where(category_id: report.category_id) if report.category_id
|
||||
filtered_results = data
|
||||
filtered_results = data.filtered_results.where(category_id: report.category_id) if report.category_id
|
||||
|
||||
report.data = []
|
||||
filtered_results.order(date: :asc)
|
||||
filtered_results.where('date >= ? AND date <= ?', report.start_date.to_date, report.end_date.to_date)
|
||||
.order(date: :asc)
|
||||
.group(:date)
|
||||
.sum(:count)
|
||||
.each do |date, count|
|
||||
|
@ -75,7 +76,10 @@ class Report
|
|||
end
|
||||
|
||||
report.total = data.sum(:count)
|
||||
report.prev30Days = filtered_results.sum(:count)
|
||||
report.prev30Days = filtered_results.where('date >= ? AND date <= ?',
|
||||
(report.start_date - 31.days).to_date,
|
||||
(report.end_date - 31.days).to_date )
|
||||
.sum(:count)
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ describe Report do
|
|||
end
|
||||
|
||||
it 'returns previous 30 days of data' do
|
||||
expect(report.prev30Days).to eq 14
|
||||
expect(report.prev30Days).to eq 35
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue