A platform for community discussion. Free, open, simple.
FIX: Blank "Legacy Pageviews" report showed no data (#29502)
Martin Brennan1c717f733c23
diff --git a/app/models/report.rb b/app/models/report.rbindex 37770371bd3..032094cc9af 100644--- a/app/models/report.rb+++ b/app/models/report.rb@@ -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_totallegacy_page_view_requestselseApplicationRequest.where(req_type: ApplicationRequest.req_types[filter])diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rbindex a507d645d4b..1830921055f 100644--- a/spec/models/report_spec.rb+++ b/spec/models/report_spec.rb@@ -312,6 +312,49 @@ RSpec.describe Report doendend+ 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" dobefore dofreeze_time(Time.now.at_midnight)