feat: remove team from rollup
This commit is contained in:
@@ -45,7 +45,6 @@ class ReportingEvents::BackfillService
|
||||
def aggregate_event_type(event_name, start_utc, end_utc)
|
||||
events = @account.reporting_events
|
||||
.where(name: event_name, created_at: start_utc...end_utc)
|
||||
.includes(:conversation)
|
||||
|
||||
return [] if events.empty?
|
||||
|
||||
@@ -95,10 +94,7 @@ class ReportingEvents::BackfillService
|
||||
{
|
||||
'account' => @account.id,
|
||||
'agent' => event.user_id,
|
||||
'inbox' => event.inbox_id,
|
||||
# Team rollups are still collected for validation/future use, but team reports
|
||||
# currently stay on the raw path because reassignment breaks rollup parity.
|
||||
'team' => event.conversation&.team_id
|
||||
'inbox' => event.inbox_id
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ module ReportingEvents::RollupService
|
||||
def perform
|
||||
return unless rollup_enabled?
|
||||
|
||||
# NOTE: Each event produces individual upserts per dimension x metric (up to 8 calls).
|
||||
# NOTE: Each event produces individual upserts per dimension x metric (up to 6 calls).
|
||||
# If this becomes a bottleneck, batch into a single upsert_all call.
|
||||
dimensions.each do |dimension_type, dimension_id|
|
||||
next if dimension_id.nil?
|
||||
@@ -44,19 +44,10 @@ module ReportingEvents::RollupService
|
||||
{
|
||||
account: @account.id,
|
||||
agent: @reporting_event.user_id,
|
||||
inbox: @reporting_event.inbox_id,
|
||||
# Team rollups are still collected for validation/future use, but team reports
|
||||
# currently stay on the raw path because reassignment breaks rollup parity.
|
||||
team: team_id
|
||||
inbox: @reporting_event.inbox_id
|
||||
}
|
||||
end
|
||||
|
||||
def team_id
|
||||
return nil if @reporting_event.conversation_id.blank?
|
||||
|
||||
@team_id ||= @reporting_event.conversation&.team_id
|
||||
end
|
||||
|
||||
def metrics_for_event
|
||||
case @reporting_event.name
|
||||
when 'conversation_resolved'
|
||||
|
||||
@@ -6,7 +6,6 @@ describe ReportingEvents::RollupService do
|
||||
let(:user) { create(:user, account: account) }
|
||||
let(:inbox) { create(:inbox, account: account) }
|
||||
let(:conversation) { create(:conversation, account: account, inbox: inbox, assignee: user) }
|
||||
let(:team) { create(:team, account: account) }
|
||||
|
||||
context 'when reporting_timezone is not set' do
|
||||
before { account.update!(reporting_timezone: nil) }
|
||||
@@ -50,7 +49,7 @@ describe ReportingEvents::RollupService do
|
||||
conversation: conversation)
|
||||
end
|
||||
|
||||
it 'creates rollup rows for all dimensions' do
|
||||
it 'creates rollup rows for account, agent, and inbox' do
|
||||
described_class.perform(reporting_event)
|
||||
|
||||
# Account dimension
|
||||
@@ -294,19 +293,6 @@ describe ReportingEvents::RollupService do
|
||||
)
|
||||
expect(agent_rows).to be_empty
|
||||
end
|
||||
|
||||
it 'loads team_id from conversation' do
|
||||
conversation.update!(team_id: team.id)
|
||||
|
||||
described_class.perform(reporting_event)
|
||||
|
||||
team_row = ReportingEventsRollup.find_by(
|
||||
account_id: account.id,
|
||||
dimension_type: 'team',
|
||||
dimension_id: team.id
|
||||
)
|
||||
expect(team_row).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
describe 'upsert behavior' do
|
||||
|
||||
Reference in New Issue
Block a user