Add signup counts to /charts/ API
This commit is contained in:
parent
7d370fe4b2
commit
d99e4e3b23
|
@ -422,6 +422,16 @@ class MemberCountSerializer(serializers.ModelSerializer):
|
||||||
model = models.StatsMemberCount
|
model = models.StatsMemberCount
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
class SignupCountSerializer(serializers.ModelSerializer):
|
||||||
|
month = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.StatsSignupCount
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_month(self, obj):
|
||||||
|
return str(obj.month)[:7]
|
||||||
|
|
||||||
|
|
||||||
class HistoryChangeSerializer(serializers.ModelSerializer):
|
class HistoryChangeSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -390,6 +390,11 @@ class MemberCountViewSet(Base, List):
|
||||||
queryset = models.StatsMemberCount.objects.all()
|
queryset = models.StatsMemberCount.objects.all()
|
||||||
serializer_class = serializers.MemberCountSerializer
|
serializer_class = serializers.MemberCountSerializer
|
||||||
|
|
||||||
|
class SignupCountViewSet(Base, List):
|
||||||
|
pagination_class = None
|
||||||
|
queryset = models.StatsSignupCount.objects.order_by('-month')[:16][::-1]
|
||||||
|
serializer_class = serializers.SignupCountSerializer
|
||||||
|
|
||||||
|
|
||||||
class BackupView(views.APIView):
|
class BackupView(views.APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
|
|
|
@ -20,6 +20,7 @@ router.register(r'sessions', views.SessionViewSet, basename='session')
|
||||||
router.register(r'training', views.TrainingViewSet, basename='training')
|
router.register(r'training', views.TrainingViewSet, basename='training')
|
||||||
router.register(r'transactions', views.TransactionViewSet, basename='transaction')
|
router.register(r'transactions', views.TransactionViewSet, basename='transaction')
|
||||||
router.register(r'charts/membercount', views.MemberCountViewSet, basename='membercount')
|
router.register(r'charts/membercount', views.MemberCountViewSet, basename='membercount')
|
||||||
|
router.register(r'charts/signupcount', views.SignupCountViewSet, basename='signupcount')
|
||||||
#router.register(r'me', views.FullMemberView, basename='fullmember')
|
#router.register(r'me', views.FullMemberView, basename='fullmember')
|
||||||
#router.register(r'registration', views.RegistrationViewSet, basename='register')
|
#router.register(r'registration', views.RegistrationViewSet, basename='register')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user