2018-07-25 09:30:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 13:17:42 +00:00
|
|
|
class UserCallout < ApplicationRecord
|
2018-01-26 16:06:52 +00:00
|
|
|
belongs_to :user
|
2018-02-02 02:07:33 +00:00
|
|
|
|
2018-11-13 16:29:14 +00:00
|
|
|
# We use `UserCalloutEnums.feature_names` here so that EE can more easily
|
|
|
|
# extend this `Hash` with new values.
|
|
|
|
enum feature_name: ::UserCalloutEnums.feature_names
|
2018-02-02 23:16:24 +00:00
|
|
|
|
2018-02-02 02:07:33 +00:00
|
|
|
validates :user, presence: true
|
2018-02-02 23:16:24 +00:00
|
|
|
validates :feature_name,
|
|
|
|
presence: true,
|
|
|
|
uniqueness: { scope: :user_id },
|
|
|
|
inclusion: { in: UserCallout.feature_names.keys }
|
2020-02-06 18:08:54 +00:00
|
|
|
|
|
|
|
scope :with_feature_name, -> (feature_name) { where(feature_name: UserCallout.feature_names[feature_name]) }
|
|
|
|
scope :with_dismissed_after, -> (dismissed_after) { where('dismissed_at > ?', dismissed_after) }
|
2018-01-26 16:06:52 +00:00
|
|
|
end
|