incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/3] git commit: [#6203] ticket:377 refactored filtered_by_subscription to a single mongo query
Date Wed, 26 Jun 2013 23:57:08 GMT
[#6203] ticket:377 refactored filtered_by_subscription to a single mongo query


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

Branch: refs/heads/master
Commit: 0b6473954be2990a784cee9037170185ebff02f4
Parents: a36f8c3
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Wed Jun 26 14:11:55 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Jun 26 23:04:30 2013 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0b647395/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 62c1021..c4e58da 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -324,9 +324,11 @@ class Globals(MappedClass):
         changed_tickets = {}
         for ticket in tickets:
             message = ''
+            new_user = None
             for k, v in sorted(values.iteritems()):
                 if k == 'assigned_to_id':
-                    new_user = User.query.get(_id=v)
+                    if not new_user:
+                        new_user = User.query.get(_id=v)
                     old_user = User.query.get(_id=getattr(ticket, k))
                     if new_user:
                         message += get_change_text(
@@ -423,23 +425,17 @@ class Globals(MappedClass):
         p_id = project_id if project_id else c.project._id
         ac_id = app_config_id if app_config_id else c.app.config._id
         ticket_ids = tickets.keys()
+        tickets_index_id = {ticket.index_id(): t_id for t_id, ticket in tickets.iteritems()}
         users = Mailbox.query.find(dict(project_id=p_id, app_config_id=ac_id))
-        users = [u.user_id for u in users]
         filtered = {}
-        for uid in users:
-            params = dict(
-                user_id=uid,
-                project_id=p_id,
-                app_config_id=ac_id)
-            if Mailbox.subscribed(**params):
-                filtered[uid] = set(ticket_ids)  # subscribed to entire tool, will see all
changes
+        for user in users:
+            if user.artifact_index_id is None:
+                filtered[user.user_id] = set(ticket_ids)  # subscribed to entire tool, will
see all changes
                 continue
-            for t_id, ticket in tickets.iteritems():
-                params.update({'artifact': ticket})
-                if Mailbox.subscribed(**params):
-                    if filtered.get(uid) is None:
-                        filtered[uid] = set()
-                    filtered[uid].add(t_id)
+            elif user.artifact_index_id in tickets_index_id.keys():
+                if filtered.get(user.user_id) is None:
+                    filtered[user.user_id] = set()
+                filtered[user.user_id].add(tickets_index_id[user.artifact_index_id])
         return filtered
 
 


Mime
View raw message