Chatwoot/app/views/api/v2/accounts/reports/teams.csv.erb
Aswin Dev P.S 15aaa8883c
feat: API to Filter reports by teams (#3066)
Add API to Filter reports by teams

Fixes: #2916
2021-09-27 21:12:08 +05:30

19 lines
820 B
Text

<% 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'))] %>