[damned-lies] Branch sorting again...
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Branch sorting again...
- Date: Thu, 27 Aug 2015 14:52:11 +0000 (UTC)
commit 1d4d8129c311c54a63c41ad130603a030d0b36a3
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Aug 27 16:51:18 2015 +0200
Branch sorting again...
Difficulty comes with the fact we are reversing the order for
normal sort.
stats/forms.py | 2 +-
stats/models.py | 2 +-
stats/tests/tests.py | 10 +++++-----
stats/views.py | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/stats/forms.py b/stats/forms.py
index e0ad414..df5c720 100644
--- a/stats/forms.py
+++ b/stats/forms.py
@@ -15,7 +15,7 @@ class ModuleBranchForm(forms.Form):
self.module = module
self.branch_fields = []
default_cat_name = None
- for branch in module.get_branches():
+ for branch in module.get_branches(reverse=True):
categs = branch.category_set.order_by('name', 'release__name')
if len(categs):
for cat in categs:
diff --git a/stats/models.py b/stats/models.py
index 50cd53d..8ee3af9 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -255,7 +255,7 @@ class Branch(models.Model):
return True
elif other.name in BRANCH_HEAD_NAMES:
return False
- return (self.weight, self.name) < (other.weight, other.name)
+ return (-self.weight, self.name) > (-other.weight, other.name)
@property
def img_url_prefix(self):
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 51fbc55..274c299 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -177,17 +177,17 @@ class ModuleTestCase(TestCase):
b2.save(update_statistics=False)
self.assertEqual(
[b.name for b in sorted(self.mod.branch_set.all())],
- ['master', 'a-branch', 'p-branch']
+ ['master', 'p-branch', 'a-branch']
)
- b2.weight = -1
- b2.save(update_statistics=False)
+ b1.weight = -1
+ b1.save(update_statistics=False)
self.assertEqual(
[b.name for b in sorted(self.mod.branch_set.all())],
- ['master', 'p-branch', 'a-branch']
+ ['master', 'a-branch', 'p-branch',]
)
self.assertEqual(
[b.name for b in self.mod.get_branches(reverse=True)],
- ['a-branch', 'p-branch', 'master']
+ ['p-branch', 'a-branch', 'master']
)
@test_scratchdir
diff --git a/stats/views.py b/stats/views.py
index 181a25b..1b658eb 100644
--- a/stats/views.py
+++ b/stats/views.py
@@ -49,7 +49,7 @@ def modules(request, format='html'):
def module(request, module_name):
mod = get_object_or_404(Module, name=module_name)
- branches = mod.get_branches(reverse=True)
+ branches = mod.get_branches()
if request.user.is_authenticated():
person = Person.get_by_user(request.user)
langs = person.get_languages()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]