Skip to content
Snippets Groups Projects
Commit 70ded014 authored by Rodrigo Muino Tomonari's avatar Rodrigo Muino Tomonari
Browse files

Merge branch 'georgekoltsov/relation_batch_export_in_batches' into 'master'

Update creation of Direct Transfer batch exports to use `in_batches`

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138815



Merged-by: default avatarRodrigo Tomonari <rtomonari@gitlab.com>
Approved-by: default avatarCarla Drago <cdrago@gitlab.com>
Approved-by: default avatarRodrigo Tomonari <rtomonari@gitlab.com>
Co-authored-by: default avatarGeorge Koltsov <gkoltsov@gitlab.com>
parents 7783b497 f8645415
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -65,19 +65,27 @@ def update_export!(event)
)
end
 
# rubocop:disable Cop/InBatches
# rubocop:disable CodeReuse/ActiveRecord
def enqueue_batch_exports
resolved_relation.each_batch(of: BATCH_SIZE) do |batch, batch_number|
batch_number = 0
resolved_relation.in_batches(of: BATCH_SIZE) do |batch|
batch_number += 1
batch_id = find_or_create_batch(batch_number).id
ids = batch.pluck(batch.model.primary_key) # rubocop:disable CodeReuse/ActiveRecord
ids = batch.pluck(batch.model.primary_key)
 
Gitlab::Cache::Import::Caching.set_add(self.class.cache_key(export.id, batch_id), ids, timeout: CACHE_DURATION)
 
RelationBatchExportWorker.perform_async(user.id, batch_id)
end
end
# rubocop:enable Cop/InBatches
 
def find_or_create_batch(batch_number)
export.batches.find_or_create_by!(batch_number: batch_number) # rubocop:disable CodeReuse/ActiveRecord
export.batches.find_or_create_by!(batch_number: batch_number)
end
# rubocop:enable CodeReuse/ActiveRecord
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment