doorcontrol: Fix divide by zero in access report deltas
This commit is contained in:
parent
fdd7011920
commit
5e6ae8ee75
@ -5,7 +5,7 @@ from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.contrib.postgres.aggregates import StringAgg
|
||||
from django.core.exceptions import BadRequest
|
||||
from django.db.models import Count, F, FloatField, Func, Q, Value, Window
|
||||
from django.db.models.functions import Lead, Trunc
|
||||
from django.db.models.functions import Lead, NullIf, Trunc
|
||||
from django.urls import path, reverse_lazy
|
||||
from django.utils.text import slugify
|
||||
from django.views.generic.list import ListView
|
||||
@ -173,7 +173,7 @@ class AccessPerUnitTime(BaseAccessReport):
|
||||
members_delta=(
|
||||
F("members")
|
||||
/ Window(
|
||||
Lead("members"),
|
||||
Lead(NullIf("members", 0.0)),
|
||||
order_by="-unit_time",
|
||||
output_field=FloatField(),
|
||||
)
|
||||
@ -184,7 +184,7 @@ class AccessPerUnitTime(BaseAccessReport):
|
||||
access_count_delta=(
|
||||
F("access_count")
|
||||
/ Window(
|
||||
Lead("access_count"),
|
||||
Lead(NullIf("access_count", 0.0)),
|
||||
order_by="-unit_time",
|
||||
output_field=FloatField(),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user