Sha256: c32bce168af71da6b685bb3e91a117b5435600424b8659220cdccb847f90dea4

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 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
    has_many :taggable_tags, as: :taggable
    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

2 entries across 2 versions & 1 rubygems

Version Path
motor-admin-0.1.39 app/models/motor/alert.rb
motor-admin-0.1.37 app/models/motor/alert.rb