feat: API to Filter reports by teams (#3066)

Add API to Filter reports by teams

Fixes: #2916
This commit is contained in:
Aswin Dev P.S
2021-09-27 21:12:08 +05:30
committed by GitHub
parent 8b7f6c691a
commit 15aaa8883c
10 changed files with 88 additions and 9 deletions

View File

@@ -0,0 +1,19 @@
<% headers = [
I18n.t('reports.team_csv.team_name'),
I18n.t('reports.team_csv.conversations_count'),
I18n.t('reports.team_csv.avg_first_response_time'),
I18n.t('reports.team_csv.avg_resolution_time')
]
%>
<%= CSV.generate_line headers %>
<% Current.account.teams.each do |team| %>
<% team_report = V2::ReportBuilder.new(Current.account, {
type: :team,
id: team.id,
since: params[:since],
until: params[:until]
}).summary %>
<% row = [ team.name, team_report[:conversations_count], (team_report[:avg_first_response_time]/60).to_i, (team_report[:avg_resolution_time]/60).to_i ] %>
<%= CSV.generate_line row %>
<% end %>
<%= CSV.generate_line [I18n.t('reports.period', since: Date.strptime(params[:since], '%s'), until: Date.strptime(params[:until], '%s'))] %>