总排名查询

This commit is contained in:
caoqianming 2020-02-21 16:52:20 +08:00
parent ec7b0d0854
commit 66d3730917
2 changed files with 11 additions and 2 deletions

Binary file not shown.

View File

@ -6182,7 +6182,13 @@ def apiexamtestdetail(req):
startnum, endnum = fenye(req)
with open('ratedata.dat','rb') as f:
data = pickle.load(f)
data['rows'] = data['rows'][startnum:endnum]
rows = data['rows']
if req.GET.get('search',None):
rows=[]
for i in data['rows']:
if req.GET.get('search') in i['user__name']:
rows.append(i)
data['rows'] = rows[startnum:endnum]
return JsonResponse(data)
@ -6195,8 +6201,11 @@ def apiexamtestrate(req):
print(alltest)
objs = ExamTestDetail.objects.filter(examtest__in=alltest,ison=1).values('user__userid','user__name','user__headimgurl','user__ubelongpart__partname').annotate(totalscore=Sum('score'),totaltook=Sum('took'),testnum=Count('user__userid')).order_by('-totalscore','totaltook')
total = objs.count()
objslist = list(objs)
for i in objslist:
i['rate'] = objslist.index(i) + 1
with open('ratedata.dat','wb') as f:
pickle.dump({'total':total,'rows':list(objs),'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
pickle.dump({'total':total,'rows':objslist,'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
return JsonResponse({"code": 1})