mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:42:53 +08:00
FIX: Blank "Legacy Pageviews" report showed no data (#29502)
Followup bd4e8422fe
In the previous commit, we introduced the `page_view_legacy_total_reqs`
report. However this was not tested properly, and due to a typo
the report returned no data.
This commit fixes the issue and adds a spec to catch this.
This commit is contained in:
parent
dc96b6e953
commit
1c717f733c
|
@ -311,7 +311,7 @@ class Report
|
|||
# This is a separate report because if people have switched over
|
||||
# to _not_ use legacy pageviews, we want to show both a Pageviews
|
||||
# and Legacy Pageviews report.
|
||||
elsif filter == :page_view_legacy_total_reqs
|
||||
elsif filter == :page_view_legacy_total
|
||||
legacy_page_view_requests
|
||||
else
|
||||
ApplicationRequest.where(req_type: ApplicationRequest.req_types[filter])
|
||||
|
|
|
@ -312,6 +312,49 @@ RSpec.describe Report do
|
|||
end
|
||||
end
|
||||
|
||||
describe "page_view_legacy_total_reqs" do
|
||||
before do
|
||||
freeze_time(Time.now.at_midnight)
|
||||
Theme.clear_default!
|
||||
end
|
||||
|
||||
let(:report) { Report.find("page_view_legacy_total_reqs") }
|
||||
|
||||
context "with no data" do
|
||||
it "works" do
|
||||
expect(report.data).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "with data" do
|
||||
before do
|
||||
CachedCounting.reset
|
||||
CachedCounting.enable
|
||||
ApplicationRequest.enable
|
||||
end
|
||||
|
||||
after do
|
||||
CachedCounting.reset
|
||||
ApplicationRequest.disable
|
||||
CachedCounting.disable
|
||||
end
|
||||
|
||||
it "works and does not count browser or mobile pageviews" do
|
||||
3.times { ApplicationRequest.increment!(:page_view_crawler) }
|
||||
8.times { ApplicationRequest.increment!(:page_view_logged_in) }
|
||||
6.times { ApplicationRequest.increment!(:page_view_logged_in_browser) }
|
||||
2.times { ApplicationRequest.increment!(:page_view_logged_in_mobile) }
|
||||
2.times { ApplicationRequest.increment!(:page_view_anon) }
|
||||
1.times { ApplicationRequest.increment!(:page_view_anon_browser) }
|
||||
4.times { ApplicationRequest.increment!(:page_view_anon_mobile) }
|
||||
|
||||
CachedCounting.flush
|
||||
|
||||
expect(report.data.sum { |r| r[:y] }).to eq(13)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "page_view_total_reqs" do
|
||||
before do
|
||||
freeze_time(Time.now.at_midnight)
|
||||
|
|
Loading…
Reference in New Issue
Block a user