doorcontrol: Add "detail by day" access report

This commit is contained in:
Adam Goldsmith 2024-02-09 12:16:30 -05:00
parent 6f1a9c0436
commit 747df72725

View File

@ -271,6 +271,34 @@ class MostActiveMembers(BaseAccessReport):
) )
class DetailByDayTable(tables.Table):
timestamp__date = tables.DateColumn(verbose_name="Date")
name = tables.Column()
access_count = tables.Column()
@register_report
class DetailByDay(BaseAccessReport):
_report_name = "Detail by Day"
table_class = DetailByDayTable
def get_table_data(self):
return (
super()
.get_table_data()
.with_member_id()
.values("timestamp__date", "member_id")
.filter(member_id__isnull=False)
.annotate(
access_count=Count("member_id"),
name=GroupConcat(
ConcatWS("forename", "surname", separator=" "), distinct=True
),
)
.order_by("-timestamp__date")
)
class BusiestDayOfWeekTable(tables.Table): class BusiestDayOfWeekTable(tables.Table):
timestamp__week_day = tables.Column("Week Day") timestamp__week_day = tables.Column("Week Day")
events = tables.Column() events = tables.Column()