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.
 
 

35 lines
1.1 KiB

from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from ..models import HadisSect, BookReference, Transmitters ,Hadis ,HadisCategory
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):
hadis_count = Hadis.objects.all().count()
category_count = HadisCategory.objects.all().count()
reference_count = BookReference.objects.count()
bookmark_count = Bookmark.objects.filter(
service=Bookmark.ServiceChoices.HADITH,
status=True
).count()
narrator_count = Transmitters.objects.count()
data = {
'hadis_count':hadis_count,
'category_count': category_count,
'reference_count': reference_count,
'bookmark_count': bookmark_count,
'narrator_count': narrator_count
}
return Response(data, status=status.HTTP_200_OK)