fixed starting date for graph on event's profile

This commit is contained in:
Danhia 2022-01-02 21:46:23 +01:00
parent afbe7f2430
commit eb23c9fac8
1 changed files with 2 additions and 3 deletions

View File

@ -277,7 +277,7 @@ def profile(request, user_name, event_slug):
somme = 0 somme = 0
solved = CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name, ctf__event=event_info).order_by('flag_date') solved = CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name, ctf__event=event_info).order_by('flag_date')
pointDatas[cat.name] = [] pointDatas[cat.name] = []
pointDatas[cat.name].append([user_obj.date_joined.timestamp() * 1000, 0]) pointDatas[cat.name].append([event_info.start_date.timestamp() * 1000, 0])
percent = (solved_count / max_count) * 100 percent = (solved_count / max_count) * 100
catsDatas.append([cat.name, solved_count, max_count, '{:.0f}'.format(percent)]) catsDatas.append([cat.name, solved_count, max_count, '{:.0f}'.format(percent)])
for flag in solved: for flag in solved:
@ -287,7 +287,7 @@ def profile(request, user_name, event_slug):
solves = CTF_flags.objects.filter(user=user_obj, ctf__event=event_info).order_by('-flag_date') solves = CTF_flags.objects.filter(user=user_obj, ctf__event=event_info).order_by('-flag_date')
solved = [] solved = []
somme = 0 somme = 0
solved.append([user_obj.date_joined.timestamp() * 1000, 0]) solved.append([event_info.start_date.timestamp() * 1000, 0])
for s in solves.reverse(): for s in solves.reverse():
somme += s.ctf.points somme += s.ctf.points
solved.append([s.flag_date.timestamp() * 1000,somme]) solved.append([s.flag_date.timestamp() * 1000,somme])
@ -321,7 +321,6 @@ def team_info(request, name, event_slug):
# get datas # get datas
solved_count += CTF_flags.objects.filter(user=user_obj, ctf__event=event_info , ctf__category__name=cat.name).count() solved_count += CTF_flags.objects.filter(user=user_obj, ctf__event=event_info , ctf__category__name=cat.name).count()
solved += CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name, ctf__event=event_info).order_by('flag_date') solved += CTF_flags.objects.filter(user=user_obj, ctf__category__name=cat.name, ctf__event=event_info).order_by('flag_date')
# pointDatas[cat.name].append([user_obj.date_joined.timestamp() * 1000, 0])
percent = (solved_count / max_count) * 100 percent = (solved_count / max_count) * 100
catsDatas.append([cat.name, solved_count, max_count, '{:.0f}'.format(percent)]) catsDatas.append([cat.name, solved_count, max_count, '{:.0f}'.format(percent)])
for flag in solved: for flag in solved: