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
|
# File 'app/services/projects/refresh_build_artifacts_size_statistics_service.rb', line 8
def execute
refresh = Projects::BuildArtifactsSizeRefresh.process_next_refresh!
return unless refresh&.running?
batch = refresh.next_batch(limit: BATCH_SIZE).to_a
if batch.any?
increments = batch.map do |artifact|
Gitlab::Counters::Increment.new(amount: artifact.size.to_i, ref: artifact.id)
end
Projects::BuildArtifactsSizeRefresh.transaction do
refresh.requeue!(batch.last.id)
ProjectStatistics.bulk_increment_statistic(refresh.project, :build_artifacts_size, increments)
end
sleep REFRESH_INTERVAL_SECONDS
else
refresh.schedule_finalize!
end
refresh
end
|