图表分析-模考未完成
This commit is contained in:
parent
48196fd713
commit
8f607c30c1
|
|
@ -10,5 +10,6 @@ urlpatterns = [
|
|||
path('admindata1/', Admindata1.as_view()),
|
||||
path('companydis/', Companydis.as_view()),
|
||||
path('consumerdis/', Consumerdis.as_view()),
|
||||
path('monitest/', Monitest.as_view()),
|
||||
path('searchcandidates/', SearchCandidates.as_view())
|
||||
]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import requests
|
|||
from lxml import etree
|
||||
from django.db.models import Count
|
||||
from rbac.models import UserProfile
|
||||
from django.db.models.functions import ExtractMonth, ExtractWeek, ExtractYear
|
||||
# Create your views here.
|
||||
|
||||
class BasicCount(APIView):
|
||||
|
|
@ -38,6 +39,22 @@ class Admindata1(APIView):
|
|||
ret['s'][0]['data'].append(i['total'])
|
||||
return Response(ret)
|
||||
|
||||
from examtest.models import ExamTest
|
||||
class Monitest(APIView):
|
||||
"""
|
||||
模拟考试数据-时间分布图
|
||||
"""
|
||||
def get(self, request):
|
||||
ret = {'x':{'name':'月份', 'data':[]}, 's':[{'name':'自助模考', 'data':[]}, {'name':'押卷模考', 'data':[]}], 't':'模考次数趋势图'}
|
||||
tmp = ExamTest.objects.exclude(consumer__create_admin__isnull=True)\
|
||||
.annotate(create_month=ExtractMonth('create_time'), create_year=ExtractYear('create_time'))\
|
||||
.values('create_month', 'create_year', 'type').order_by('create_year', 'create_month').annotate(total=Count('create_month'))
|
||||
for i in tmp:
|
||||
if str(i['create_year'])+'年'+str(i['create_month'])+'月' not in ret['x']['data']:
|
||||
ret['x']['data'].append(str(i['create_year'])+'年'+str(i['create_month'])+'月')
|
||||
|
||||
return Response(ret)
|
||||
|
||||
nameMap = {
|
||||
"南海诸岛" : "南海诸岛",
|
||||
'北京市' :'北京',
|
||||
|
|
|
|||
Loading…
Reference in New Issue