From 9b98ebf23a464d388b9791bc9a0fb511da43498c Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 4 Jun 2020 02:28:20 +0000 Subject: [PATCH] Add card scan stats to API --- apiserver/apiserver/api/serializers.py | 5 +++++ apiserver/apiserver/api/views.py | 5 +++++ apiserver/apiserver/urls.py | 1 + 3 files changed, 11 insertions(+) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index d4f7b26..9a342fd 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -433,6 +433,11 @@ class SignupCountSerializer(serializers.ModelSerializer): def get_month(self, obj): return str(obj.month)[:7] +class SpaceActivitySerializer(serializers.ModelSerializer): + class Meta: + model = models.StatsSpaceActivity + fields = '__all__' + class HistoryChangeSerializer(serializers.ModelSerializer): class Meta: diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 1812092..083011e 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -399,6 +399,11 @@ class SignupCountViewSet(Base, List): # have to use method as slicing breaks makemigrations return models.StatsSignupCount.objects.order_by('-month')[:16][::-1] +class SpaceActivityViewSet(Base, List): + pagination_class = None + queryset = models.StatsSpaceActivity.objects.all() + serializer_class = serializers.SpaceActivitySerializer + class BackupView(views.APIView): def get(self, request): diff --git a/apiserver/apiserver/urls.py b/apiserver/apiserver/urls.py index 4192cb9..3bfbfab 100644 --- a/apiserver/apiserver/urls.py +++ b/apiserver/apiserver/urls.py @@ -22,6 +22,7 @@ router.register(r'training', views.TrainingViewSet, basename='training') router.register(r'transactions', views.TransactionViewSet, basename='transaction') router.register(r'charts/membercount', views.MemberCountViewSet, basename='membercount') router.register(r'charts/signupcount', views.SignupCountViewSet, basename='signupcount') +router.register(r'charts/spaceactivity', views.SpaceActivityViewSet, basename='spaceactivity') #router.register(r'me', views.FullMemberView, basename='fullmember') #router.register(r'registration', views.RegistrationViewSet, basename='register')