Implement basic metrics
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
|
Loading…
Reference in New Issue