feat: APIs to filter reports (#2889)

Fixes #2823
This commit is contained in:
Tejaswini Chile
2021-08-27 22:46:32 +05:30
committed by GitHub
parent f94abaef5f
commit 65f3e83afd
19 changed files with 542 additions and 61 deletions

View File

@@ -32,9 +32,16 @@ class V2::ReportBuilder
private
def scope
return account if params[:type].match?('account')
return inbox if params[:type].match?('inbox')
return user if params[:type].match?('agent')
case params[:type]
when :account
account
when :inbox
inbox
when :agent
user
when :label
label
end
end
def inbox
@@ -45,6 +52,10 @@ class V2::ReportBuilder
@user ||= account.users.where(id: params[:id]).first
end
def label
@label ||= account.labels.where(id: params[:id]).first
end
def conversations_count
scope.conversations
.group_by_day(:created_at, range: range, default_value: 0)