Implement basic metrics
This commit is contained in:
parent
df9493f6cd
commit
f5d2b7ee7c
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class MetricsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "shiftregister.metrics"
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,7 @@
|
|||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.metrics, name="metrics"),
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
from django.http import HttpResponse
|
||||
from shiftregister.app.models import Helper
|
||||
|
||||
|
||||
def metrics(request):
|
||||
response = HttpResponse("\n".join((f"shiftregister_{name} {value}" for name, value in (
|
||||
("helpers_total", Helper.objects.count()),
|
||||
("helpers_confirmed_total", Helper.objects.filter(number_validated=True).count()),
|
||||
))))
|
||||
response.headers["Content-Type"] = "text/plain"
|
||||
|
||||
return response
|
|
@ -43,6 +43,7 @@ INSTALLED_APPS = [
|
|||
"shiftregister.importer.apps.ImporterConfig",
|
||||
"shiftregister.team.apps.TeamConfig",
|
||||
"shiftregister.pages.apps.PagesConfig",
|
||||
"shiftregister.metrics.apps.MetricsConfig",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
|
|
|
@ -21,4 +21,5 @@ urlpatterns = [
|
|||
path("team/", include("shiftregister.team.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
path("p/", include("shiftregister.pages.urls")),
|
||||
path("metrics/", include("shiftregister.metrics.urls")),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue