Sha256: c8b2cf0300008427295001bdd1fa7458ad3a1b7e17f5861ad45a8a777de7450d

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

class MailEngine::ReportsController < MailEngine::ApplicationController
  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
  end

  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
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mail_engine-0.1.14 app/controllers/mail_engine/reports_controller.rb
mail_engine-0.1.13 app/controllers/mail_engine/reports_controller.rb
mail_engine-0.1.12 app/controllers/mail_engine/reports_controller.rb
mail_engine-0.1.11 app/controllers/mail_engine/reports_controller.rb
mail_engine-0.1.10 app/controllers/mail_engine/reports_controller.rb
mail_engine-0.1.9 app/controllers/mail_engine/reports_controller.rb