Download:
child 68:58a9dddf8731
parent 66:db31e73bde12
67:cdceebad7d96
Anton Shestakov <av6@dwimlabs.net>, Sat, 25 Jun 2016 22:11:38 +0800
incoming: use a subquery for Check.ordinal instead of a separate query

2 файлов изменено, 6 вставок(+), 1 удалений(-) [+]
candolint/models.py file | annotate | diff | comparison | revisions
incoming.py file | annotate | diff | comparison | revisions
--- a/candolint/models.py Sat Jun 25 18:16:39 2016 +0800
+++ b/candolint/models.py Sat Jun 25 22:11:38 2016 +0800
@@ -97,3 +97,8 @@
if seconds or not minutes:
result.append('{} sec'.format(seconds))
return ' '.join(result)
+
+ @classmethod
+ def get_next_ordinal(cls, project):
+ count = cls.select(pw.fn.COUNT(cls.id)).where(cls.project == project)
+ return count + 1
--- a/incoming.py Sat Jun 25 18:16:39 2016 +0800
+++ b/incoming.py Sat Jun 25 22:11:38 2016 +0800
@@ -166,7 +166,7 @@
project=project)
Check.create(
- ordinal=Check.select().where(Check.project == project).count() + 1,
+ ordinal=Check.get_next_ordinal(project),
errors=errors,
warnings=warnings,
lines=json_encode(result),