diff options
Diffstat (limited to 'app/models/user_status.rb')
-rw-r--r-- | app/models/user_status.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/user_status.rb b/app/models/user_status.rb index 0e1ae0b7338..1c8634e47c3 100644 --- a/app/models/user_status.rb +++ b/app/models/user_status.rb @@ -7,6 +7,16 @@ class UserStatus < ApplicationRecord DEFAULT_EMOJI = 'speech_balloon' + CLEAR_STATUS_QUICK_OPTIONS = { + '30_minutes' => 30.minutes, + '3_hours' => 3.hours, + '8_hours' => 8.hours, + '1_day' => 1.day, + '3_days' => 3.days, + '7_days' => 7.days, + '30_days' => 30.days + }.freeze + belongs_to :user enum availability: { not_set: 0, busy: 1 } @@ -15,5 +25,11 @@ class UserStatus < ApplicationRecord validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names } validates :message, length: { maximum: 100 }, allow_blank: true + scope :scheduled_for_cleanup, -> { where(arel_table[:clear_status_at].lteq(Time.current)) } + cache_markdown_field :message, pipeline: :emoji + + def clear_status_after=(value) + self.clear_status_at = CLEAR_STATUS_QUICK_OPTIONS[value]&.from_now + end end |