Add stats endpoint for tracking computer logins
This commit is contained in:
parent
1e5250eb70
commit
0f826015f7
|
@ -23,6 +23,7 @@ DEFAULTS = {
|
||||||
'bay_110_temp': None,
|
'bay_110_temp': None,
|
||||||
'minecraft_players': [],
|
'minecraft_players': [],
|
||||||
'card_scans': 0,
|
'card_scans': 0,
|
||||||
|
'track': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
def changed_card():
|
def changed_card():
|
||||||
|
|
|
@ -16,7 +16,7 @@ from rest_auth.views import PasswordChangeView, PasswordResetView, PasswordReset
|
||||||
from rest_auth.registration.views import RegisterView
|
from rest_auth.registration.views import RegisterView
|
||||||
from fuzzywuzzy import fuzz, process
|
from fuzzywuzzy import fuzz, process
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import datetime
|
import datetime, time
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -421,6 +421,16 @@ class StatsViewSet(viewsets.ViewSet, List):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise exceptions.ValidationError(dict(data='This field is required.'))
|
raise exceptions.ValidationError(dict(data='This field is required.'))
|
||||||
|
|
||||||
|
@action(detail=False, methods=['post'])
|
||||||
|
def track(self, request):
|
||||||
|
if 'name' in request.data:
|
||||||
|
track = cache.get('track', {})
|
||||||
|
track[request.data['name']] = time.time()
|
||||||
|
cache.set('track', track)
|
||||||
|
return Response(200)
|
||||||
|
else:
|
||||||
|
raise exceptions.ValidationError(dict(paste='This field is required.'))
|
||||||
|
|
||||||
|
|
||||||
class MemberCountViewSet(Base, List):
|
class MemberCountViewSet(Base, List):
|
||||||
pagination_class = None
|
pagination_class = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user