Reduce the number of SQL queries in the "Check Details" page.

This commit is contained in:
Pēteris Caune 2020-03-05 16:15:02 +02:00
parent eb7f51f6f5
commit fcf11d5b4f
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
2 changed files with 3 additions and 2 deletions

View File

@ -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,

View File

@ -193,10 +193,10 @@
<h2>Notification Methods</h2>
<table id="details-integrations" class="table">
{% for channel in channels %}
<tr data-url="{% url 'hc-switch-channel' check.code channel.code %}" {% if channel in check.channel_set.all %}class="on"{% endif %}>
<tr data-url="{% url 'hc-switch-channel' check.code channel.code %}" {% if channel in enabled_channels %}class="on"{% endif %}>
<th>
<span class="label">
{% if channel in check.channel_set.all %}ON{% else %}OFF{% endif %}
{% if channel in enabled_channels %}ON{% else %}OFF{% endif %}
</span>
</th>
<td>