You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2024/07/02 22:41:12 UTC

(allura) branch dw/8565 updated (a8cc8f4cf -> 8b6f7a8da)

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

dill0wn pushed a change to branch dw/8565
in repository https://gitbox.apache.org/repos/asf/allura.git


    from a8cc8f4cf replace uses of Collection.count() with Collection.estimated_document_count()
     new 68461687e drop pymongo/ming  method
     new 8bb18c453 fixup! replace uses of Collection.count() with Collection.estimated_document_count()
     new 8b6f7a8da fixup! update ming calls from find_and_modify to find_one_and_update

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Allura/allura/lib/custom_middleware.py       |  4 +-
 Allura/allura/model/auth.py                  |  2 +-
 Allura/allura/model/monq_model.py            |  2 +-
 Allura/allura/model/notification.py          |  5 +--
 Allura/allura/model/repository.py            |  2 +-
 Allura/allura/tests/model/test_filesystem.py | 60 ++++++++++++++--------------
 ForgeImporters/forgeimporters/base.py        |  4 +-
 ForgeTracker/forgetracker/model/ticket.py    |  2 +-
 8 files changed, 40 insertions(+), 41 deletions(-)


(allura) 02/03: fixup! replace uses of Collection.count() with Collection.estimated_document_count()

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch dw/8565
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 8bb18c4536bb2fde8606f1dc1515cb991212cbd9
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Tue Jul 2 13:29:30 2024 -0400

    fixup! replace uses of Collection.count() with Collection.estimated_document_count()
---
 Allura/allura/tests/model/test_filesystem.py | 60 ++++++++++++++--------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/Allura/allura/tests/model/test_filesystem.py b/Allura/allura/tests/model/test_filesystem.py
index 8d2b46de8..3b2e54db1 100644
--- a/Allura/allura/tests/model/test_filesystem.py
+++ b/Allura/allura/tests/model/test_filesystem.py
@@ -56,9 +56,9 @@ class TestFile(TestCase):
     def test_from_stream(self):
         f = File.from_stream('test1.txt', BytesIO(b'test1'))
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 1
-        assert self.db.fs.chunks.estimated_document_count() == 1
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 1
+        assert self.db.fs.chunks.count_documents({}) == 1
         assert f.filename == 'test1.txt'
         assert f.content_type == 'text/plain'
         self._assert_content(f, b'test1')
@@ -66,9 +66,9 @@ class TestFile(TestCase):
     def test_from_data(self):
         f = File.from_data('test2.txt', b'test2')
         self.session.flush(f)
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 1
-        assert self.db.fs.chunks.estimated_document_count() == 1
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 1
+        assert self.db.fs.chunks.count_documents({}) == 1
         assert f.filename == 'test2.txt'
         assert f.content_type == 'text/plain'
         self._assert_content(f, b'test2')
@@ -77,50 +77,50 @@ class TestFile(TestCase):
         path = __file__.rstrip('c')
         f = File.from_path(path)
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 1
-        assert self.db.fs.chunks.estimated_document_count() >= 1
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 1
+        assert self.db.fs.chunks.count_documents({}) >= 1
         assert f.filename == os.path.basename(path)
         text = f.rfile().read()
 
     def test_delete(self):
         f = File.from_data('test1.txt', b'test1')
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 1
-        assert self.db.fs.chunks.estimated_document_count() == 1
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 1
+        assert self.db.fs.chunks.count_documents({}) == 1
         f.delete()
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 0
-        assert self.db.fs.files.estimated_document_count() == 0
-        assert self.db.fs.chunks.estimated_document_count() == 0
+        assert self.db.fs.count_documents({}) == 0
+        assert self.db.fs.files.count_documents({}) == 0
+        assert self.db.fs.chunks.count_documents({}) == 0
 
     def test_remove(self):
         File.from_data('test1.txt', b'test1')
         File.from_data('test2.txt', b'test2')
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 2
-        assert self.db.fs.files.estimated_document_count() == 2
-        assert self.db.fs.chunks.estimated_document_count() == 2
+        assert self.db.fs.count_documents({}) == 2
+        assert self.db.fs.files.count_documents({}) == 2
+        assert self.db.fs.chunks.count_documents({}) == 2
         File.remove(dict(filename='test1.txt'))
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 1
-        assert self.db.fs.chunks.estimated_document_count() == 1
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 1
+        assert self.db.fs.chunks.count_documents({}) == 1
 
     def test_overwrite(self):
         f = File.from_data('test1.txt', b'test1')
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 1
-        assert self.db.fs.chunks.estimated_document_count() == 1
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 1
+        assert self.db.fs.chunks.count_documents({}) == 1
         self._assert_content(f, b'test1')
         with f.wfile() as fp:
             fp.write(b'test2')
         self.session.flush()
-        assert self.db.fs.estimated_document_count() == 1
-        assert self.db.fs.files.estimated_document_count() == 2
-        assert self.db.fs.chunks.estimated_document_count() == 2
+        assert self.db.fs.count_documents({}) == 1
+        assert self.db.fs.files.count_documents({}) == 2
+        assert self.db.fs.chunks.count_documents({}) == 2
         self._assert_content(f, b'test2')
 
     def test_serve_embed(self):
@@ -167,9 +167,9 @@ class TestFile(TestCase):
         assert t.content_type == 'image/png'
         assert t.is_image()
         assert f.filename == t.filename
-        assert self.db.fs.estimated_document_count() == 2
-        assert self.db.fs.files.estimated_document_count() == 2
-        assert self.db.fs.chunks.estimated_document_count() == 2
+        assert self.db.fs.count_documents({}) == 2
+        assert self.db.fs.files.count_documents({}) == 2
+        assert self.db.fs.chunks.count_documents({}) == 2
 
     def test_not_image(self):
         f, t = File.save_image(


(allura) 03/03: fixup! update ming calls from find_and_modify to find_one_and_update

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch dw/8565
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 8b6f7a8da8245cc51c4d17f98f1d499bbf1be954
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Tue Jul 2 18:41:03 2024 -0400

    fixup! update ming calls from find_and_modify to find_one_and_update
---
 Allura/allura/model/auth.py               | 2 +-
 Allura/allura/model/monq_model.py         | 2 +-
 Allura/allura/model/notification.py       | 5 ++---
 Allura/allura/model/repository.py         | 2 +-
 ForgeImporters/forgeimporters/base.py     | 4 ++--
 ForgeTracker/forgetracker/model/ticket.py | 2 +-
 6 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index cb797e776..17818c829 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -219,7 +219,7 @@ class AuthGlobals(MappedClass):
         cls.upsert()
         g = cls.query.find_one_and_update(
             {}, update={'$inc': {'next_uid': 1}},
-            new=True)
+            return_document=True)
         return g.next_uid
 
 
diff --git a/Allura/allura/model/monq_model.py b/Allura/allura/model/monq_model.py
index 17b4aa47e..4dbc532dc 100644
--- a/Allura/allura/model/monq_model.py
+++ b/Allura/allura/model/monq_model.py
@@ -206,7 +206,7 @@ class MonQTask(MappedClass):
                             state='busy',
                             process=process)
                     },
-                    new=True,
+                    return_document=True,
                     sort=cls.sort)
                 if obj is not None:
                     return obj
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 942a34b66..5b08cf1e8 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -597,8 +597,7 @@ class Mailbox(MappedClass):
                 update={'$set': dict(
                     queue=[],
                     queue_empty=True,
-                )},
-                new=False)
+                )})
 
         for mbox in take_while_true(find_and_modify_direct_mbox):
             try:
@@ -625,7 +624,7 @@ class Mailbox(MappedClass):
                         queue=[],
                         queue_empty=True,
                         )},
-                new=False)
+                )
             mbox.fire(now)
 
     def fire(self, now):
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 3266fe0a8..e51cdcd60 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1075,7 +1075,7 @@ class CommitStatus(MappedClass):
         obj = cls.query.find_one_and_update(
             dict(commit_id=kw.get('commit_id'), context=kw.get('context')),
             update={'$set': kw},
-            new=True,
+            return_document=True,
             upsert=True,
         )
         return obj
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 7c87c6a78..db14405df 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -475,7 +475,7 @@ class ToolImporter(metaclass=ToolImporterMeta):
                 ],
             },
             update={'$inc': {pending_key: 1}},
-            new=True,
+            return_document=True,
         )
         return modified_project is not None
 
@@ -488,7 +488,7 @@ class ToolImporter(metaclass=ToolImporterMeta):
         M.Project.query.find_one_and_update(
             {'_id': project._id},
             update={'$inc': {pending_key: -1}},
-            new=True,
+            return_document=True,
         )
 
     def import_tool(self, project, user, project_name=None,
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 01714d071..1b80511d8 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -142,7 +142,7 @@ class Globals(MappedClass):
         gbl = Globals.query.find_one_and_update(
             dict(app_config_id=self.app_config_id),
             update={'$inc': {'last_ticket_num': 1}},
-            new=True)
+            return_document=True)
         session(gbl).expunge(gbl)
         return gbl.last_ticket_num
 


(allura) 01/03: drop pymongo/ming method

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch dw/8565
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 68461687e0230b4bda18050f4892c665f525c9a6
Author: Dillon Walls <di...@slashdotmedia.com>
AuthorDate: Tue Jul 2 11:42:48 2024 -0400

    drop pymongo/ming  method
---
 Allura/allura/lib/custom_middleware.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 1baf4c4f1..c1af2d3b3 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -328,7 +328,7 @@ class AlluraTimerMiddleware(TimerMiddleware):
                   'insert_now', 'update_now', 'delete_now',
                   'find', 'find_one_and_update', 'find_one_and_replace', 'find_one_and_delete', 
                   'remove', 'update', 'update_if_not_modified',
-                  'aggregate', 'group', 'distinct',
+                  'aggregate', 'distinct',
                   ),
             # Timer('ming', ming.schema.Document, 'validate',
             #       debug_each_call=False),
@@ -336,7 +336,7 @@ class AlluraTimerMiddleware(TimerMiddleware):
             #       '_validate_fast_missing', '_validate_optional',
             #       debug_each_call=False),
             Timer('mongo', pymongo.collection.Collection, 'count', 'find',
-                  'find_one', 'aggregate', 'group', 
+                  'find_one', 'aggregate', 
                   'find_one_and_update', 'find_one_and_replace', 'find_one_and_delete', 
                   'insert', 'save', 'update', 'remove', 'drop'),
             Timer('mongo', pymongo.cursor.Cursor, 'count', 'distinct',