lib/picky/query/allocations.rb in picky-4.23.0 vs lib/picky/query/allocations.rb in picky-4.23.1
- old
+ new
@@ -113,10 +113,11 @@
#
# Note: It's possible that no ids are returned by an allocation, but a count. (In case of an offset)
#
def process! amount, offset = 0, terminate_early = nil, sorting = nil
each do |allocation|
+ sorting = nil if amount <= 0 # Stop sorting if the results aren't shown.
calculated_ids = allocation.process! amount, offset, sorting
if calculated_ids.empty?
offset = offset - allocation.count unless offset.zero?
else
amount = amount - calculated_ids.size # we need less results from the following allocation
@@ -138,9 +139,10 @@
# Note: Slower than #process! especially with large offsets.
#
def process_unique! amount, offset = 0, terminate_early = nil, sorting = nil
unique_ids = []
each do |allocation|
+ sorting = nil if amount <= 0 # Stop sorting if the results aren't shown.
calculated_ids = allocation.process_with_illegals! amount, 0, unique_ids, sorting
projected_offset = offset - allocation.count
unique_ids += calculated_ids # uniq this? <- No, slower than just leaving duplicates.
if projected_offset <= 0
allocation.ids.slice!(0, offset)
\ No newline at end of file