feat: add validity gate

This commit is contained in:
Shivam Mishra
2026-03-09 13:57:49 +05:30
parent 014393297b
commit 6f127d86b9
3 changed files with 17 additions and 3 deletions
@@ -30,10 +30,10 @@ module ReportingEvents::RollupService
private
# NOTE: This is intentionally not gated by the reporting_events_rollup feature flag.
# Rollup data is collected for all accounts with a reporting timezone (soft toggle).
# Rollup data is collected for all accounts with a valid reporting timezone (soft toggle).
# The feature flag only controls the read path — whether reports query rollups or raw events.
def rollup_enabled?
@account.reporting_timezone.present?
@account.reporting_timezone.present? && ActiveSupport::TimeZone[@account.reporting_timezone].present?
end
def event_date
@@ -301,7 +301,7 @@ describe V2::Reports::Concerns::RollupConditions do
end
it 'returns false when account timezone is not recognized' do
account.update!(reporting_timezone: 'Invalid/Zone')
allow(account).to receive(:reporting_timezone).and_return('Invalid/Zone')
builder.params = { timezone_offset: current_ny_offset }
expect(builder.timezone_matches_account?).to be false
end
@@ -23,6 +23,20 @@ describe ReportingEvents::RollupService do
end
end
context 'when reporting_timezone is invalid' do
it 'skips rollup creation' do
reporting_event = create(:reporting_event,
account: account,
name: 'conversation_resolved',
conversation: conversation)
allow(account).to receive(:reporting_timezone).and_return('Invalid/Zone')
expect do
described_class.perform(reporting_event)
end.not_to change(ReportingEventsRollup, :count)
end
end
context 'when reporting_timezone is set' do
describe 'conversation_resolved event' do
let(:reporting_event) do