Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created June 18, 2014 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogdan/e66c1be9f7764a4f2d2e to your computer and use it in GitHub Desktop.
Save bogdan/e66c1be9f7764a4f2d2e to your computer and use it in GitHub Desktop.
%table.action_table.table.table-striped.table-bordered
%thead.header
%tr
%th{style: "width: 210px", rowspan: 2} Email Type
%th{style: "width: 75px", rowspan: 2} Sent
%th{colspan: 2} Delivered
%th{colspan: 2} Opened
%th{colspan: 2} Clicked
%th{colspan: 2} Complained
%tr
%th{style: "width: 60px"}
%th{style: "width: 35px"} %
%th{style: "width: 60px"}
%th{style: "width: 35px"} %
%th{style: "width: 60px"}
%th{style: "width: 35px"} %
%th{style: "width: 60px"}
%th{style: "width: 35px"} %
- grid = EmailPerformanceGrid.new
- (SentEmail::REASONS.keys).each do |reason|
- data = @scope.find{|row| row.reason == reason}
%tr
%td= SentEmail::REASONS[reason]
- if data
= datagrid_row(grid, data) do |row|
%td= row.sent_count
%td= row.delivered_count
%td= row.delivered_percent
%td= data.opened_count
%td= row.opened_percent
%td= row.clicked_count
%td= row.clicked_percent
%td= row.complained_count
%td= row.complained_percent
- else
- 9.times do
%td
%tr.result
%td Total
%td= sent_total = @scope.inject(0) {|sum, row| sum += row.sent_count }
%td= delivered_total = @scope.inject(0) {|sum, row| sum += row.delivered_count }
%td= number_to_percentage(delivered_total.to_f / sent_total * 100, precision: 1)
%td= opened_total = @scope.inject(0) {|sum, row| sum += row.opened_count }
%td= number_to_percentage(opened_total.to_f / sent_total * 100, precision: 1)
%td= clicked_total = @scope.inject(0) {|sum, row| sum += row.clicked_count }
%td= number_to_percentage(clicked_total.to_f / sent_total * 100, precision: 1)
%td= complained_total = @scope.inject(0) {|sum, row| sum += row.complained_count }
%td= number_to_percentage(complained_total.to_f / sent_total * 100, precision: 1)
- graph_options = {render_to: "graph-main", stacking: true, title: "Emails", unit: 'Emails', categories: SentEmail::REASONS.values }
= render partial: 'shared/highcharts/bar', locals: { options: graph_options, data: @grid.data_for_graph }
- first_date, graph_data = @grid.data_for_graph_group_by_dates
- if graph_data.any?
%h2.page-header Detalization by Dates
- graph_data.each do |reason, values|
.page-delimeter
%h4.page-subheader= SentEmail::REASONS[reason]
- graph_options = {start_date: first_date, date_interval: 1.day.to_i, render_to: "graph-#{reason}", unit: 'Emails'}
= render partial: 'shared/highcharts/area', locals: { options: graph_options, data: values }
- graph_options.merge!(render_to: "graph-#{reason}_percent", tooltip_suffix: "%", unit: "%", min: 0, max: 100)
= render partial: 'shared/highcharts/line', locals: { options: graph_options, data: Highcharts.data_convert_to_percent(values) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment