diff options
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index 18fa8aaaa16..131416d1bee 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -43,6 +43,8 @@ class Key < ApplicationRecord scope :preload_users, -> { preload(:user) } scope :for_user, -> (user) { where(user: user) } scope :order_last_used_at_desc, -> { reorder(::Gitlab::Database.nulls_last_order('last_used_at', 'DESC')) } + scope :expired_today_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') = CURRENT_DATE AND expiry_notification_delivered_at IS NULL"]) } + scope :expiring_soon_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') > CURRENT_DATE AND date(expires_at AT TIME ZONE 'UTC') < ? AND before_expiry_notification_delivered_at IS NULL", DAYS_TO_EXPIRE.days.from_now.to_date]) } def self.regular_keys where(type: ['Key', nil]) |