2018-02-26 09:06:04 -05:00
|
|
|
require 'logger'
|
|
|
|
require 'resolv-replace'
|
|
|
|
|
|
|
|
desc "GitLab | Archive legacy traces to trace artifacts"
|
|
|
|
namespace :gitlab do
|
|
|
|
namespace :traces do
|
|
|
|
task archive: :environment do
|
|
|
|
logger = Logger.new(STDOUT)
|
|
|
|
logger.info('Archiving legacy traces')
|
|
|
|
|
2018-06-03 01:21:50 -04:00
|
|
|
Ci::Build.finished.without_archived_trace
|
2018-02-27 11:24:23 -05:00
|
|
|
.order(id: :asc)
|
|
|
|
.find_in_batches(batch_size: 1000) do |jobs|
|
|
|
|
job_ids = jobs.map { |job| [job.id] }
|
2018-02-26 09:06:04 -05:00
|
|
|
|
2018-03-06 06:20:36 -05:00
|
|
|
ArchiveTraceWorker.bulk_perform_async(job_ids)
|
2018-02-27 11:24:23 -05:00
|
|
|
|
2018-02-28 04:43:19 -05:00
|
|
|
logger.info("Scheduled #{job_ids.count} jobs. From #{job_ids.min} to #{job_ids.max}")
|
2018-02-27 11:24:23 -05:00
|
|
|
end
|
2018-02-26 09:06:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|