feat: Improve Report API performance (#9476)

- Re-write the methods for clarity
- Remove the dependency on the ReportHelper class.
- Remove n+1 queries in the average metric time series data.
This commit is contained in:
Pranav
2024-05-22 17:34:24 -07:00
committed by GitHub
parent 023b3ad507
commit 87d92f73d4
13 changed files with 545 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ RSpec.describe 'Reports API', type: :request do
let!(:user) { create(:user, account: account) }
let!(:inbox) { create(:inbox, account: account) }
let(:inbox_member) { create(:inbox_member, user: user, inbox: inbox) }
let(:default_timezone) { ActiveSupport::TimeZone[0]&.name }
let(:default_timezone) { 'UTC' }
let(:start_of_today) { Time.current.in_time_zone(default_timezone).beginning_of_day.to_i }
let(:end_of_today) { Time.current.in_time_zone(default_timezone).end_of_day.to_i }
let(:params) { { timezone_offset: Time.zone.utc_offset } }
@@ -18,7 +18,7 @@ RSpec.describe 'Reports API', type: :request do
assignee: user, created_at: Time.current.in_time_zone(default_timezone).to_date)
end
describe 'GET /api/v2/accounts/:account_id/reports/account' do
describe 'GET /api/v2/accounts/:account_id/reports' do
context 'when it is an unauthenticated user' do
it 'returns unauthorized' do
get "/api/v2/accounts/#{account.id}/reports"