You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1015 B

from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from ..models import HadisSect, BookReference, Transmitters
from ..docs import hadis_info_swagger
from apps.bookmark.models import Bookmark
class HadisInfoView(APIView):
"""
API view to get hadis statistics
"""
@hadis_info_swagger
def get(self, request, *args, **kwargs):
category_count = HadisSect.objects.filter(is_active=True).count()
reference_count = BookReference.objects.count()
bookmark_count = Bookmark.objects.filter(
service=Bookmark.ServiceChoices.HADITH,
status=True
).count()
narrator_count = Transmitters.objects.count()
data = {
'category_count': category_count,
'reference_count': reference_count,
'bookmark_count': bookmark_count,
'narrator_count': narrator_count
}
return Response(data, status=status.HTTP_200_OK)