allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [allura] 03/03: Sort by shortlink newest first, in case there are multiple matches the first one will be used. Tangentially related to [#7996]?
Date Mon, 10 Aug 2020 12:57:28 GMT
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 <dave@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):


Mime
View raw message