Download:
child 142:41d0a4c7376a
parent 140:fa50e7dd9d91
141:61eb02ffa9d3
Anton Shestakov <av6@dwimlabs.net>, Sat, 16 Jul 2016 19:05:11 +0800
viewer: request light fields when using just metadata from Check / and project pages just link to checks, so the heavier text fields like Check.lines aren't actually important, and can be excluded from SELECT for a nice performance boost.

2 файлов изменено, 9 вставок(+), 2 удалений(-) [+]
candolint/handlers.py file | annotate | diff | comparison | revisions
candolint/models.py file | annotate | diff | comparison | revisions
--- a/candolint/handlers.py Thu Jul 14 17:04:03 2016 +0800
+++ b/candolint/handlers.py Sat Jul 16 19:05:11 2016 +0800
@@ -53,7 +53,7 @@
class IndexHandler(BaseHandler):
def get(self):
checks = (Check
- .select(Check, Project, Change)
+ .select(Project, Change, *Check.get_light_fields())
.join(Project)
.switch(Check)
.join(Change)
@@ -65,7 +65,7 @@
def get(self, domain, user, name):
project = get_project_or_404(domain, user, name)
checks = (Check
- .select(Check, Change)
+ .select(Change, *Check.get_light_fields())
.join(Change)
.where(Check.project == project)
.limit(10))
--- a/candolint/models.py Thu Jul 14 17:04:03 2016 +0800
+++ b/candolint/models.py Sat Jul 16 19:05:11 2016 +0800
@@ -119,3 +119,10 @@
.select(pw.fn.COALESCE(pw.fn.MAX(cls.ordinal), 0))
.where(cls.project == project))
return max_ordinal + 1
+
+ @classmethod
+ def get_light_fields(cls):
+ return [
+ field for field in cls._meta.fields.values()
+ if not isinstance(field, pw.TextField)
+ ]