diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-12 21:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-12 21:08:59 +0300 |
commit | 6d533fe8b44007d82b8de29a4b706da69e5f5936 (patch) | |
tree | f02d924a3b8f81ca28852c993831fcf596417f1b /app/models/user_status.rb | |
parent | f44248b613e94534fd6a1b1f8fb6df179f1bbf56 (diff) |
Add latest changes from gitlab-org/gitlab@master
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 |