Sha256: 39cf0dfd4f86b4434dc7d5982b3d56ed74a8cc7e9d96d9c0e8422d41658b6d39

Contents?: true

Size: 674 Bytes

Versions: 2

Compression:

Stored size: 674 Bytes

Contents

module Chaskiq
  class Metric < ActiveRecord::Base
    belongs_to :trackable, polymorphic: true, required: true

    #system output
    scope :deliveries, ->{where(action: "deliver")}

    #user feedback
    scope :bounces, ->{ where(action: "bounce")}
    scope :opens,   ->{ where(action: "open") }
    scope :clicks,  ->{ where(action: "click")}
    scope :spams,   ->{ where(action: "spam") }

    #reportery
    scope :uniques, ->{group("host")}


    def style_class
      case self.action
      when "deliver"
        "plain"
      when "open"
        "information"
      when "click"
        "primary"
      when "spam"
        "danger"
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chaskiq-0.0.3 app/models/chaskiq/metric.rb
chaskiq-0.0.2 app/models/chaskiq/metric.rb