Class: MailEngine::ReportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/mail_engine/reports_controller.rb

Constant Summary

Constants included from MailEngine

PLACEHOLDERS_IN_LAYOUT, VERSION

Instance Method Summary collapse

Methods inherited from ApplicationController

#close_modal_and_refresh

Instance Method Details

#chartObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/mail_engine/reports_controller.rb', line 28

def chart
  if ['bounces', 'blocks', 'spamreports', 'invalidemails'].include?(params[:type])
    @result = Array.wrap(MailEngine::Sendgrid::RestApi.send(params[:type], :date => 1)) || []
    render "mail_engine/reports/charts/#{params[:type]}"
  else
    flash[:notice] = "Error chart type."
    redirect_to :back
  end
end

#indexObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/mail_engine/reports_controller.rb', line 2

def index
  @pie_chart_columns = ["bounces", "unique_opens", "spamreports", "blocks", "unopened"]
  @stat_columns = [
    "requests",
    "delivered",
    "blocks",
    "invalid_email",
    "clicks",
    "unique_clicks",
    "opens",
    "unique_opens",
    "bounces",
    "repeat_bounces",
    "spamreports",
    "repeat_spamreports",
    "unsubscribes",
    "repeat_unsubscribes"
  ]
  @stats_data = if params[:report] and params[:report][:from] and params[:report][:to]
                  MailEngine::Sendgrid::RestApi.stats(:start_date => params[:report][:from], :end_date => params[:report][:to])
                else
                  MailEngine::Sendgrid::RestApi.stats(:days => 7)
                end
  @stats_data ||= {}
end