doorcontrol: Add unique member count to "busiest..." reports
All checks were successful
Ruff / ruff (push) Successful in 23s

This commit is contained in:
Adam Goldsmith 2024-02-09 12:20:01 -05:00
parent 747df72725
commit d4670a7d02

View File

@ -302,6 +302,7 @@ class DetailByDay(BaseAccessReport):
class BusiestDayOfWeekTable(tables.Table):
timestamp__week_day = tables.Column("Week Day")
events = tables.Column()
members = tables.Column()
def render_timestamp__week_day(self, value):
return calendar.day_name[(value - 2) % 7]
@ -317,14 +318,18 @@ class BusiestDayOfWeek(BaseAccessReport):
return (
super()
.get_table_data()
.with_member_id()
.values("timestamp__week_day")
.annotate(events=Count("timestamp"))
.annotate(
events=Count("timestamp"), members=Count("member_id", distinct=True)
)
)
class BusiestTimeOfDayTable(tables.Table):
timestamp__hour = tables.TemplateColumn("{{ value }}:00", verbose_name="Hour")
events = tables.Column()
members = tables.Column()
@register_report
@ -337,6 +342,9 @@ class BusiestTimeOfDay(BaseAccessReport):
return (
super()
.get_table_data()
.with_member_id()
.values("timestamp__hour")
.annotate(events=Count("timestamp"))
.annotate(
events=Count("timestamp"), members=Count("member_id", distinct=True)
)
)