Browse Source

Optimize /checks/status: load and parse the template once, not N times.

pull/178/head
Pēteris Caune 7 years ago
parent
commit
0e8226b5d7
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      hc/front/views.py

+ 3
- 2
hc/front/views.py View File

@ -11,7 +11,7 @@ from django.db.models import Count
from django.http import (Http404, HttpResponse, HttpResponseBadRequest,
HttpResponseForbidden, JsonResponse)
from django.shortcuts import get_object_or_404, redirect, render
from django.template.loader import render_to_string
from django.template.loader import get_template, render_to_string
from django.urls import reverse
from django.utils import timezone
from django.utils.crypto import get_random_string
@ -90,6 +90,7 @@ def status(request):
checks = list(Check.objects.filter(user_id=request.team.user_id))
details = []
tmpl = get_template("front/last_ping_cell.html")
for check in checks:
status = "grace" if check.in_grace_period() else check.get_status()
@ -97,7 +98,7 @@ def status(request):
details.append({
"code": str(check.code),
"status": status,
"last_ping": render_to_string("front/last_ping_cell.html", ctx)
"last_ping": tmpl.render(ctx)
})
tags_statuses, num_down = _tags_statuses(checks)


Loading…
Cancel
Save