From 2ec8b65f18a4e1136777dd14e8984612b691ed69 Mon Sep 17 00:00:00 2001 From: Valeria Chemtai Date: Tue, 16 May 2017 16:29:05 +0300 Subject: [PATCH 1/2] [Feature #143401489]Add new dashboard for failed checks --- hc/front/urls.py | 1 + hc/front/views.py | 32 ++++++++++++++++++++++++++++++++ templates/base.html | 13 +++++++++++-- templates/front/my_checks.html | 5 +++++ 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/hc/front/urls.py b/hc/front/urls.py index 244b191..f18d332 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -34,6 +34,7 @@ urlpatterns = [ url(r'^$', views.index, name="hc-index"), url(r'^checks/$', views.my_checks, name="hc-checks"), + url(r'^failedchecks/$', views.failedchecks, name="hc-failedchecks"), url(r'^checks/add/$', views.add_check, name="hc-add-check"), url(r'^checks/cron_preview/$', views.cron_preview), url(r'^checks/([\w-]+)/', include(check_urls)), diff --git a/hc/front/views.py b/hc/front/views.py index c409dd2..d08028a 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -68,6 +68,38 @@ def my_checks(request): return render(request, "front/my_checks.html", ctx) +def failedchecks(request): + q = Check.objects.filter(user=request.team.user).order_by("created") + checks = list(q) + failed_checks = list() + + counter = Counter() + down_tags, grace_tags = set(), set() + for check in checks: + status = check.get_status() + if status == "down": + failed_checks.append(check) + for tag in check.tags_list(): + if tag == "": + continue + counter[tag] += 1 + down_tags.add(tag) + checks = failed_checks + + ctx = { + "page": "failedchecks", + "checks": checks, + "now": timezone.now(), + "tags": counter.most_common(), + "down_tags": down_tags, + "grace_tags": grace_tags, + "ping_endpoint": settings.PING_ENDPOINT, + "timezones": all_timezones + } + + return render(request, "front/failed_checks.html", ctx) + + def _welcome_check(request): check = None if "welcome_code" in request.session: diff --git a/templates/base.html b/templates/base.html index 254dec6..424f014 100644 --- a/templates/base.html +++ b/templates/base.html @@ -75,9 +75,17 @@ {% if request.user.is_authenticated %} diff --git a/templates/front/my_checks.html b/templates/front/my_checks.html index 2c36dd6..38f1357 100644 --- a/templates/front/my_checks.html +++ b/templates/front/my_checks.html @@ -7,6 +7,7 @@ {% block content %}
+ {% block check_title %}

{% if request.team == request.user.profile %} My Checks @@ -14,6 +15,7 @@

{{ request.team.team_name }} {% endif %}

+ {% endblock %}
{% if tags %}
@@ -32,6 +34,7 @@

+ {% if checks %} {% include "front/my_checks_mobile.html" %} {% include "front/my_checks_desktop.html" %} @@ -40,6 +43,7 @@

{% endif %}

+{% block add_check_button %}
@@ -48,6 +52,7 @@

+{% endblock %}