Welcome to mirror list, hosted at ThFree Co, Russian Federation.

purge_dependency_proxy_cache_worker.rb « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 615fa81f28e19d8c6d13a5aa3a8b320068800096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

class PurgeDependencyProxyCacheWorker
  include ApplicationWorker

  data_consistency :always

  sidekiq_options retry: 3
  include Gitlab::Allowable
  idempotent!

  queue_namespace :dependency_proxy
  feature_category :dependency_proxy

  UPDATE_BATCH_SIZE = 100

  def perform(current_user_id, group_id)
    @current_user = User.find_by_id(current_user_id)
    @group = Group.find_by_id(group_id)

    return unless valid?

    @group.dependency_proxy_blobs.each_batch(of: UPDATE_BATCH_SIZE) do |batch|
      batch.update_all(status: :expired)
    end

    @group.dependency_proxy_manifests.each_batch(of: UPDATE_BATCH_SIZE) do |batch|
      batch.update_all(status: :expired)
    end
  end

  private

  def valid?
    return unless @group

    can?(@current_user, :admin_group, @group)
  end
end