From fcf11d5b4f91f1a5adaf593b2b7b2ec4c9311b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Thu, 5 Mar 2020 16:15:02 +0200 Subject: [PATCH] Reduce the number of SQL queries in the "Check Details" page. --- hc/front/views.py | 1 + templates/front/details.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hc/front/views.py b/hc/front/views.py index b42bd9cb..1bcb6c3a 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -521,6 +521,7 @@ def details(request, code): "project": check.project, "check": check, "channels": channels, + "enabled_channels": list(check.channel_set.all()), "timezones": pytz.all_timezones, "downtimes": check.downtimes(months=3), "is_new": "new" in request.GET, diff --git a/templates/front/details.html b/templates/front/details.html index 1eb7e008..0f4f9459 100644 --- a/templates/front/details.html +++ b/templates/front/details.html @@ -193,10 +193,10 @@

Notification Methods

{% for channel in channels %} - +
- {% if channel in check.channel_set.all %}ON{% else %}OFF{% endif %} + {% if channel in enabled_channels %}ON{% else %}OFF{% endif %}