Download:
child 301:508c24e708e0
parent 299:18a3583a520a
300:c9294e82e4f6
Anton Shestakov <av6@dwimlabs.net>, Sat, 23 Sep 2017 12:42:03 +0800
viewer: use order_by() explicitly, helps with keeping indices up-to-date

2 файлов изменено, 12 вставок(+), 8 удалений(-) [+]
candolint/handlers.py file | annotate | diff | comparison | revisions
candolint/models.py file | annotate | diff | comparison | revisions
--- a/candolint/handlers.py Wed Sep 20 13:44:36 2017 +0800
+++ b/candolint/handlers.py Sat Sep 23 12:42:03 2017 +0800
@@ -88,7 +88,8 @@
.join(Project)
.switch(Check)
.join(Change)
- .group_by(Check.project))
+ .group_by(Check.project)
+ .order_by(Check.finished.desc(), Check.ordinal.desc()))
self.render('index.html', checks=checks)
@@ -98,7 +99,8 @@
checks = (Check
.select(Change, *Check.get_light_fields())
.join(Change)
- .where(Check.project == project))
+ .where(Check.project == project)
+ .order_by(Check.ordinal.desc()))
self.render('project.html', project=project, checks=checks)
@@ -108,7 +110,8 @@
checks = (Check
.select(Change, *Check.get_light_fields())
.join(Change)
- .where(Check.project == project))
+ .where(Check.project == project)
+ .order_by(Check.ordinal.desc()))
def status(check):
if not check.success:
return 'unknown'
@@ -164,12 +167,12 @@
.select(*Check.get_light_fields())
.join(Change)
.where(Check.project == check.project)
- .where(Change.branch == check.change.branch))
+ .where(Change.branch == check.change.branch)
+ .order_by(Check.ordinal.desc()))
more = checks.where(Check.ordinal >= check.ordinal).count()
limit = 50
history = list(reversed(checks
- .order_by(Check.ordinal.desc())
.limit(limit)
.offset(max(0, more - limit))))
if len(history) > 2:
@@ -229,7 +232,8 @@
project = get_project_or_404(domain, user, name)
checks = (Check
.select(*Check.get_light_fields())
- .where(Check.project == project))
+ .where(Check.project == project)
+ .order_by(Check.ordinal.desc()))
branch = self.get_argument('branch', None)
if branch is not None:
checks = checks.join(Change).where(Change.branch == branch)
@@ -262,7 +266,8 @@
project = get_project_or_404(domain, user, name)
checks = (Check
.select(*Check.get_light_fields())
- .where(Check.project == project))
+ .where(Check.project == project)
+ .order_by(Check.ordinal.desc()))
if check_num != 'latest':
checks = checks.where(Check.ordinal == check_num)
branch = self.get_argument('branch', None)
--- a/candolint/models.py Wed Sep 20 13:44:36 2017 +0800
+++ b/candolint/models.py Sat Sep 23 12:42:03 2017 +0800
@@ -94,7 +94,6 @@
change = pw.ForeignKeyField(Change, related_name='checks')
class Meta:
- order_by = ('-finished', '-ordinal')
indexes = (
(('ordinal', 'project'), True),
(('project', 'finished', 'ordinal'), True)