This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch db/shortlink_latest in repository https://gitbox.apache.org/repos/asf/allura.git
commit f06a6b54bdb366d698f7596f9498c59945f30106 Author: Dave Brondsema <d...@brondsema.net> AuthorDate: Thu Aug 6 15:10:11 2020 -0400 Sort by shortlink newest first, in case there are multiple matches the first one will be used. Tangentially related to [#7996]? --- Allura/allura/model/index.py | 12 ++++++++---- Allura/allura/tests/test_tasks.py | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Allura/allura/model/index.py b/Allura/allura/model/index.py index e22c8da..c4b9bec 100644 --- a/Allura/allura/model/index.py +++ b/Allura/allura/model/index.py @@ -167,10 +167,14 @@ class Shortlink(object): links_by_artifact[unquote(d['artifact'])].append(d) else: result[link] = parsed_links.pop(link) - q = cls.query.find(dict( - link={'$in': list(links_by_artifact.keys())}, - project_id={'$in': list(project_ids)} - ), validate=False) + q = cls.query.find( + dict( + link={'$in': list(links_by_artifact.keys())}, + project_id={'$in': list(project_ids)} + ), + validate=False, + sort=[('_id', pymongo.DESCENDING)], # if happen to be multiple (ticket move?) have newest first + ) matches_by_artifact = dict( (link, list(matches)) for link, matches in groupby(q, key=lambda s: unquote(s.link))) diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py index c2d9117..98d2e7e 100644 --- a/Allura/allura/tests/test_tasks.py +++ b/Allura/allura/tests/test_tasks.py @@ -539,6 +539,7 @@ I'm not here''' message) assert_equal(hm.call_count, 0) + class TestUserNotificationTasks(TestController): def setUp(self): super(TestUserNotificationTasks, self).setUp() @@ -569,6 +570,7 @@ class TestUserNotificationTasks(TestController): assert_in('by Test Admin', text) assert_in('auth/subscriptions#notifications', text) + class TestNotificationTasks(unittest.TestCase): def setUp(self):