Commit cc5136f1 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'mc/bug/reduce-ci-minute-namespace-notification-db-load' into 'master'

Reduce DB load when resetting CI minute notifications

See merge request gitlab-org/gitlab!55765
parents 7158662c 31d878a6
---
title: Reduce DB load when resetting CI minute notifications.
merge_request: 55765
author:
type: performance
...@@ -69,6 +69,11 @@ module EE ...@@ -69,6 +69,11 @@ module EE
where("EXISTS (?)", matcher) where("EXISTS (?)", matcher)
end end
scope :without_last_ci_minutes_notification, -> do
where.not(last_ci_minutes_notification_at: nil)
.or(where.not(last_ci_minutes_usage_notification_level: nil))
end
delegate :shared_runners_seconds, :shared_runners_seconds_last_reset, to: :namespace_statistics, allow_nil: true delegate :shared_runners_seconds, :shared_runners_seconds_last_reset, to: :namespace_statistics, allow_nil: true
delegate :additional_purchased_storage_size, :additional_purchased_storage_size=, delegate :additional_purchased_storage_size, :additional_purchased_storage_size=,
......
...@@ -111,9 +111,10 @@ module Ci ...@@ -111,9 +111,10 @@ module Ci
end end
def reset_ci_minutes_notifications!(namespaces) def reset_ci_minutes_notifications!(namespaces)
namespaces.update_all( namespaces.without_last_ci_minutes_notification.update_all(
last_ci_minutes_notification_at: nil, last_ci_minutes_notification_at: nil,
last_ci_minutes_usage_notification_level: nil) last_ci_minutes_usage_notification_level: nil
)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment