From b8a0effbb2c2e12e86b8cb920c7d2815fe9ab9b2 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 18 Feb 2023 19:26:43 +0000 Subject: [PATCH] Add last scanned ID to stats --- apiserver/apiserver/api/utils_stats.py | 1 + apiserver/apiserver/api/views.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/apiserver/apiserver/api/utils_stats.py b/apiserver/apiserver/api/utils_stats.py index 3adf999..021a722 100644 --- a/apiserver/apiserver/api/utils_stats.py +++ b/apiserver/apiserver/api/utils_stats.py @@ -28,6 +28,7 @@ DEFAULTS = { 'sign': '', 'link': '', 'autoscan': '', + 'last_scan': {}, } if secrets.MUMBLE: diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index f7b92e0..714f30a 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -629,6 +629,12 @@ class DoorViewSet(viewsets.ViewSet, List): t = utils.now_alberta_tz().strftime('%Y-%m-%d %H:%M:%S, %a %I:%M %p') logger.info('Scan - Time: {} | Name: {} {} ({})'.format(t, member.preferred_name, member.last_name, member.id)) + last_scan = dict( + time=time.time(), + member_id=member.id, + ) + cache.set('last_scan', last_scan) + utils_stats.calc_card_scans() return Response(200)