Sha256: 178e1637d43da9ab4ccc31f12a8c8dabd2dd09dd1df456bedb063c622d4c3810

Contents?: true

Size: 669 Bytes

Versions: 9

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

module Motor
  class Alert < ::Motor::ApplicationRecord
    audited

    belongs_to :query
    belongs_to :author, polymorphic: true, optional: true

    has_many :alert_locks, dependent: :destroy
    has_many :taggable_tags, as: :taggable, dependent: :destroy
    has_many :tags, through: :taggable_tags, class_name: 'Motor::Tag'

    serialize :preferences, HashSerializer

    scope :active, -> { where(deleted_at: nil) }
    scope :enabled, -> { where(is_enabled: true) }

    def cron
      @cron ||=
        Fugit::Nat.parse("#{preferences[:interval]} #{ActiveSupport::TimeZone::MAPPING[preferences[:timezone]]}")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
motor-admin-0.1.49 app/models/motor/alert.rb
motor-admin-0.1.48 app/models/motor/alert.rb
motor-admin-0.1.47 app/models/motor/alert.rb
motor-admin-0.1.46 app/models/motor/alert.rb
motor-admin-0.1.44 app/models/motor/alert.rb
motor-admin-0.1.43 app/models/motor/alert.rb
motor-admin-0.1.42 app/models/motor/alert.rb
motor-admin-0.1.41 app/models/motor/alert.rb
motor-admin-0.1.40 app/models/motor/alert.rb