This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git


The following commit(s) were added to refs/heads/master by this push:
     new c125f0c9e chunked_find: avoid redundant query at end
c125f0c9e is described below

commit c125f0c9e89730ed2d622c3cdaa8db5df8da33c7
Author: Dave Brondsema <dbronds...@slashdotmedia.com>
AuthorDate: Tue Oct 18 12:33:17 2022 -0400

    chunked_find: avoid redundant query at end
---
 Allura/allura/lib/utils.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 28a621038..b6e7ee0de 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -176,12 +176,14 @@ def chunked_find(cls, query=None, pagesize=1024, 
sort_key='_id', sort_dir=1):
         else:
             # skipping requires scanning, even for an indexed query
             q = cls.query.find(query).limit(pagesize).skip(pagesize * page)
-        results = (q.all())
+        results = q.all()
         if not results:
             break
         if sort_key:
             max_id = results[-1][sort_key]
         yield results
+        if len(results) < pagesize:
+            break
         page += 1
 
 

Reply via email to