diff options
Diffstat (limited to 'app/models/container_registry/event.rb')
-rw-r--r-- | app/models/container_registry/event.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/app/models/container_registry/event.rb b/app/models/container_registry/event.rb index c1b865ae578..5409bdf5af4 100644 --- a/app/models/container_registry/event.rb +++ b/app/models/container_registry/event.rb @@ -2,6 +2,8 @@ module ContainerRegistry class Event + include Gitlab::Utils::StrongMemoize + ALLOWED_ACTIONS = %w(push delete).freeze PUSH_ACTION = 'push' EVENT_TRACKING_CATEGORY = 'container_registry:notification' @@ -17,7 +19,7 @@ module ContainerRegistry end def handle! - # no op + update_project_statistics end def track! @@ -58,10 +60,25 @@ module ContainerRegistry end def container_registry_path - path = event.dig('target', 'repository') - return unless path + strong_memoize(:container_registry_path) do + path = event.dig('target', 'repository') + next unless path + + ContainerRegistry::Path.new(path) + end + end + + def project + container_registry_path&.repository_project + end + + def update_project_statistics + return unless supported? + return unless target_tag? + return unless project + return unless Feature.enabled?(:container_registry_project_statistics, project) - ContainerRegistry::Path.new(path) + ProjectCacheWorker.perform_async(project.id, [], [:container_registry_size]) end end end |