Download:
child 115:2311bfce57b4
parent 113:c7bd4a3f0db5
114:7314f0b864b8
Anton Shestakov <av6@dwimlabs.net>, Wed, 06 Jul 2016 16:43:51 +0800
viewer: join change table in check handler for performance reasons

1 файлов изменено, 7 вставок(+), 4 удалений(-) [+]
candolint/handlers.py file | annotate | diff | comparison | revisions
--- a/candolint/handlers.py Wed Jul 06 14:04:30 2016 +0800
+++ b/candolint/handlers.py Wed Jul 06 16:43:51 2016 +0800
@@ -75,10 +75,13 @@
class CheckHandler(BaseHandler):
def get(self, domain, user, name, check_num, format_='html'):
project = get_project_or_404(domain, user, name)
- if check_num == 'latest':
- check = get_or_404(Check, project=project)
- else:
- check = get_or_404(Check, project=project, ordinal=check_num)
+ check_query = (Check
+ .select(Check, Change)
+ .join(Change)
+ .where(Check.project == project))
+ if check_num != 'latest':
+ check_query = check_query.where(Check.ordinal == check_num)
+ check = get_or_404(check_query)
lines = json_decode(check.lines)
if format_ == 'raw':
self.get_raw(project, check, lines)