You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2020/08/10 12:57:28 UTC
[allura] 03/03: Sort by shortlink newest first,
in case there are multiple matches the first one will be used.
Tangentially related to [#7996]?
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit dbfda1d4dbaec3ac717fd2d99de83c2f09be53e8
Author: Dave Brondsema <da...@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 146e82a..0b8a3a4 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 63b18ad..6c82b52 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):