summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-04-17 06:24:33 +0200
committerDan McGee <dan@archlinux.org>2013-04-17 06:24:33 +0200
commit81821d2b4791f18635b13394aa57fa0795acddaf (patch)
tree3715cf6f1b5cf2f8a1c45ff9d5c8230624f15615 /main
parentb7b24740640e24883cd17fd683e1d465fbb343f8 (diff)
downloadarchweb-81821d2b4791f18635b13394aa57fa0795acddaf.tar.gz
archweb-81821d2b4791f18635b13394aa57fa0795acddaf.tar.xz
Sort required by entries by dependency type
We were doing this for depends entries already, and we can do the same for required by entries via some absolutely awesome SQL query magic and injecting a few more things to our already crazy query. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r--main/models.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py
index 24aeed8..2f4d352 100644
--- a/main/models.py
+++ b/main/models.py
@@ -193,14 +193,22 @@ class Package(models.Model):
category as this package if that check makes sense.
"""
from packages.models import Depend
+ sorttype = '''(CASE deptype
+ WHEN 'D' THEN 0
+ WHEN 'O' THEN 1
+ WHEN 'M' THEN 2
+ WHEN 'C' THEN 3
+ ELSE 1000 END)'''
name_clause = '''packages_depend.name IN (
SELECT %s UNION ALL
SELECT z.name FROM packages_provision z WHERE z.pkg_id = %s
)'''
requiredby = Depend.objects.select_related('pkg',
'pkg__arch', 'pkg__repo').extra(
- where=[name_clause], params=[self.pkgname, self.id]).order_by(
- 'pkg__pkgname', 'pkg__arch__name', 'pkg__repo__name')
+ select={'sorttype': sorttype},
+ where=[name_clause], params=[self.pkgname, self.id]).order_by(
+ 'sorttype', 'pkg__pkgname',
+ 'pkg__arch__name', 'pkg__repo__name')
if not self.arch.agnostic:
# make sure we match architectures if possible
requiredby = requiredby.filter(