incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#5023] change mailbox find_and_modify loop to be a single query loop
Date Wed, 03 Oct 2012 20:36:59 GMT
Updated Branches:
  refs/heads/db/5023 78ab60f9a -> abff15a56


[#5023] change mailbox find_and_modify loop to be a single query loop


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/abff15a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/abff15a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/abff15a5

Branch: refs/heads/db/5023
Commit: abff15a568b3efc88e032408fdbb101861610983
Parents: 78ab60f
Author: Dave Brondsema <dbrondsema@geek.net>
Authored: Wed Oct 3 20:36:51 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Wed Oct 3 20:36:51 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/notification.py |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/abff15a5/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 704bf18..73efcc4 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -450,14 +450,18 @@ class Mailbox(MappedClass):
         q_digest = dict(
             type={'$in': ['digest', 'summary']},
             next_scheduled={'$lt':now})
-        for mbox in cls.query.find(q_direct):
+
+        def find_mboxes():
             mbox = cls.query.find_and_modify(
-                query=dict(_id=mbox._id),
-                update={'$set': dict(
-                            queue=[],
-                            queue_empty=True,
-                        )},
-                new=False)
+                    query=q_direct,
+                    update={'$set': dict(
+                                queue=[],
+                                queue_empty=True,
+                            )},
+                    new=False)
+            if mbox:
+                yield mbox
+        for mbox in find_mboxes():
             mbox.fire(now)
         for mbox in cls.query.find(q_digest):
             next_scheduled = now


Mime
View raw message