Skip to content

Commit

Permalink
Bug: Force scoping message metrics to account_id (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
subintp committed Apr 22, 2020
1 parent b98a64d commit dba6866
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/builders/v2/report_builder.rb
Expand Up @@ -50,14 +50,15 @@ def conversations_count
.count
end

# unscoped removes all scopes added to a model previously
def incoming_messages_count
scope.messages.unscoped.incoming
scope.messages.unscoped.where(account_id: account.id).incoming
.group_by_day(:created_at, range: range, default_value: 0)
.count
end

def outgoing_messages_count
scope.messages.unscoped.outgoing
scope.messages.unscoped.where(account_id: account.id).outgoing
.group_by_day(:created_at, range: range, default_value: 0)
.count
end
Expand Down

0 comments on commit dba6866

Please sign in to comment.