This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch db/8360 in repository https://gitbox.apache.org/repos/asf/allura.git
commit dc2e27545f34970c0525e0abca391e2251856f85 Author: Dave Brondsema <d...@brondsema.net> AuthorDate: Mon May 4 18:40:23 2020 -0400 [#8360] some minor short-circuiting speedups --- Allura/allura/lib/helpers.py | 2 +- Allura/allura/model/neighborhood.py | 2 +- Allura/allura/model/notification.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py index f51cc96..4007ed2 100644 --- a/Allura/allura/lib/helpers.py +++ b/Allura/allura/lib/helpers.py @@ -646,7 +646,7 @@ def pop_user_notifications(user=None): if user is None: user = c.user mbox = M.Mailbox.query.get(user_id=user._id, is_flash=True) - if mbox: + if mbox and mbox.queue: notifications = M.Notification.query.find( dict(_id={'$in': mbox.queue})) mbox.queue = [] diff --git a/Allura/allura/model/neighborhood.py b/Allura/allura/model/neighborhood.py index 6a08117..74c18ac 100644 --- a/Allura/allura/model/neighborhood.py +++ b/Allura/allura/model/neighborhood.py @@ -164,7 +164,7 @@ class Neighborhood(MappedClass): return (self.neighborhood_project .app_config_by_tool_type('home') is not None) - @property + @LazyProperty def icon(self): # New icon storage uses the neighborhood_project object, so Project.icon* methods can be shared if self.neighborhood_project.get_tool_data('allura', 'icon_original_size'): diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py index 4a2cded..1b8ee27 100644 --- a/Allura/allura/model/notification.py +++ b/Allura/allura/model/notification.py @@ -625,6 +625,9 @@ class Mailbox(MappedClass): ''' Send all notifications that this mailbox has enqueued. ''' + if len(self.queue) == 0: + return + notifications = Notification.query.find(dict(_id={'$in': self.queue})) notifications = notifications.all() if len(notifications) != len(self.queue):