summaryrefslogtreecommitdiff
path: root/app/models/container_registry
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /app/models/container_registry
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
downloadgitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'app/models/container_registry')
-rw-r--r--app/models/container_registry/event.rb25
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