Browse Source

info view and docs updated'

master
Mohsen Taba 5 months ago
parent
commit
64deea83d4
  1. 9
      apps/hadis/docs.py
  2. 7
      apps/hadis/views/info.py

9
apps/hadis/docs.py

@ -842,10 +842,11 @@ hadis_info_swagger = swagger_auto_schema(
description="Hadis database statistics", description="Hadis database statistics",
examples={ examples={
"application/json":{ "application/json":{
"category_count": 25,
"reference_count": 150,
"bookmark_count": 75,
"narrator_count": 200
"hadis_count": 65,
"category_count": 67,
"reference_count": 1,
"bookmark_count": 0,
"narrator_count": 8
} }
} }
), ),

7
apps/hadis/views/info.py

@ -2,7 +2,8 @@ from rest_framework.views import APIView
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework import status from rest_framework import status
from ..models import HadisSect, BookReference, Transmitters
from ..models import HadisSect, BookReference, Transmitters ,Hadis ,HadisCategory
from ..docs import hadis_info_swagger from ..docs import hadis_info_swagger
from apps.bookmark.models import Bookmark from apps.bookmark.models import Bookmark
@ -14,7 +15,8 @@ class HadisInfoView(APIView):
@hadis_info_swagger @hadis_info_swagger
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
category_count = HadisSect.objects.filter(is_active=True).count()
hadis_count = Hadis.objects.all().count()
category_count = HadisCategory.objects.all().count()
reference_count = BookReference.objects.count() reference_count = BookReference.objects.count()
bookmark_count = Bookmark.objects.filter( bookmark_count = Bookmark.objects.filter(
service=Bookmark.ServiceChoices.HADITH, service=Bookmark.ServiceChoices.HADITH,
@ -23,6 +25,7 @@ class HadisInfoView(APIView):
narrator_count = Transmitters.objects.count() narrator_count = Transmitters.objects.count()
data = { data = {
'hadis_count':hadis_count,
'category_count': category_count, 'category_count': category_count,
'reference_count': reference_count, 'reference_count': reference_count,
'bookmark_count': bookmark_count, 'bookmark_count': bookmark_count,

Loading…
Cancel
Save