Skip to content
Snippets Groups Projects
Commit 5fabe7ca authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Yield current batch and total count when indexing

parent 74b023d0
No related branches found
No related tags found
1 merge request!19Yield current batch and total count when indexing
Pipeline #
Loading
Loading
@@ -91,8 +91,9 @@ module Elasticsearch
from, to = parse_revs(from_rev, to_rev)
 
diff = repository_for_indexing.diff(from, to)
deltas = diff.deltas
 
diff.deltas.reverse.each_slice(BLOBS_BATCH) do |slice|
deltas.reverse.each_slice(BLOBS_BATCH) do |slice|
bulk_operations = slice.map do |delta|
if delta.status == :deleted
next if delta.old_file[:mode].to_s(8) == "160000"
Loading
Loading
@@ -106,6 +107,8 @@ module Elasticsearch
end
 
perform_bulk bulk_operations
yield slice, deltas.length if block_given?
end
 
ObjectSpace.garbage_collect
Loading
Loading
@@ -197,6 +200,8 @@ module Elasticsearch
end
 
perform_bulk bulk_operations
yield batch, commit_oids.length if block_given?
end
 
ObjectSpace.garbage_collect
Loading
Loading
Loading
Loading
@@ -106,4 +106,31 @@ describe TestRepository do
expect(TestRepository.__elasticsearch__.search('test').results.count).to eq(6)
expect(repo.search('test')[:commits][:total_count]).to eq(3)
end
it "yields current batch and total length when indexing commits" do
count = 0
total = 0
repo.index_commits do |batch, total_count|
count += batch.length
total = total_count
end
expect(count).to be > 0
expect(count).to eq(total)
end
it "yields current batch and total length when indexing blobs" do
count = 0
total = 0
repo.index_blobs do |batch, total_count|
count += batch.length
total = total_count
end
expect(count).to be > 0
expect(count).to eq(total)
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