repos
/ status-django master

status-django

mirror archived upstream

Self-hostable uptime monitor and status page on Django: HTTP checks, Lighthouse audits, SEO crawls, and email and Discord alerts.

djangodockerhandcodedpythonself-hostedsqlitestatus-pageuptime-monitoringvite

838 B · 32 lines · Python Raw History
 1import uuid
 2
 3from django.db import models
 4from django.contrib.auth.models import AbstractUser
 5
 6
 7class User(AbstractUser):
 8    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
 9
10    discord_webhook_url = models.URLField(blank=True, null=True)
11
12    def __str__(self):
13        return self.username
14
15    @property
16    def total_properties(self):
17        return self.properties.count()
18
19    @property
20    def total_checks(self):
21        total_checks = 0
22        for property in self.properties.all():
23            total_checks += property.total_checks
24        return total_checks
25
26    @property
27    def total_properties_down(self):
28        total_properties_down = 0
29        for property in self.properties.all():
30            total_properties_down += property.current_status != 200
31        return total_properties_down