forked from GithubBackups/healthchecks
Improve project sorting in the "My Projects" page
Primary sort key: projects with overall_status=down go first Secondary sort key: project's name
This commit is contained in:
parent
4587b45cab
commit
738a648407
@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Improve HTML email display in the "Ping Details" dialog
|
- Improve HTML email display in the "Ping Details" dialog
|
||||||
- Add a link to check's details page in Slack notifications
|
- Add a link to check's details page in Slack notifications
|
||||||
- Replace details_url with cloaked_url in email and chat notifications
|
- Replace details_url with cloaked_url in email and chat notifications
|
||||||
|
- In the "My Projects" page, show projects with failing checks first
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
- Fix downtime summary to handle months when the check didn't exist yet (#472)
|
- Fix downtime summary to handle months when the check didn't exist yet (#472)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from functools import cached_property
|
||||||
from secrets import token_urlsafe
|
from secrets import token_urlsafe
|
||||||
from urllib.parse import quote, urlencode
|
from urllib.parse import quote, urlencode
|
||||||
import uuid
|
import uuid
|
||||||
@ -342,6 +343,7 @@ class Project(models.Model):
|
|||||||
for profile in q:
|
for profile in q:
|
||||||
profile.update_next_nag_date()
|
profile.update_next_nag_date()
|
||||||
|
|
||||||
|
@cached_property
|
||||||
def overall_status(self):
|
def overall_status(self):
|
||||||
status = "up"
|
status = "up"
|
||||||
for check in self.check_set.all():
|
for check in self.check_set.all():
|
||||||
|
@ -13,7 +13,7 @@ from django.contrib import messages
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core import signing
|
from django.core import signing
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db.models import Count
|
from django.db.models import Count, F
|
||||||
from django.http import (
|
from django.http import (
|
||||||
Http404,
|
Http404,
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
@ -275,7 +275,17 @@ def switch_channel(request, code, channel_code):
|
|||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
projects = list(request.profile.projects())
|
project_ids = request.profile.projects().values("id")
|
||||||
|
|
||||||
|
q = Project.objects.filter(id__in=project_ids)
|
||||||
|
q = q.annotate(n_checks=Count("check", distinct=True))
|
||||||
|
q = q.annotate(n_channels=Count("channel", distinct=True))
|
||||||
|
q = q.annotate(owner_email=F("owner__email"))
|
||||||
|
|
||||||
|
projects = list(q)
|
||||||
|
# Primary sort key: projects with overall_status=down go first
|
||||||
|
# Secondary sort key: project's name
|
||||||
|
projects.sort(key=lambda p: (p.overall_status != "down", p.name))
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
"page": "projects",
|
"page": "projects",
|
||||||
|
@ -21,16 +21,14 @@
|
|||||||
<h4>{{ project }}</h4>
|
<h4>{{ project }}</h4>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{% with project.check_set.count as n %}
|
{{ project.n_checks }}
|
||||||
{{ n }} check{{ n|pluralize }},
|
check{{ project.n_checks|pluralize }},
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
{% with project.channel_set.count as n %}
|
{{ project.n_channels }}
|
||||||
{{ n }} integration{{ n|pluralize }}
|
integration{{ project.n_channels|pluralize }}
|
||||||
{% endwith %}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="text-muted">
|
<div class="text-muted">
|
||||||
{{ project.owner.email }}
|
{{ project.owner_email }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user