Fix rerate logic (DMOJ)
This commit is contained in:
parent
297b8a2a36
commit
b45de198ba
10 changed files with 77 additions and 78 deletions
|
@ -35,7 +35,7 @@ def api_v1_contest_detail(request, contest):
|
|||
can_see_rankings = contest.can_see_full_scoreboard(request.user)
|
||||
problems = list(contest.contest_problems.select_related('problem')
|
||||
.defer('problem__description').order_by('order'))
|
||||
participations = (contest.users.filter(virtual=0, user__is_unlisted=False)
|
||||
participations = (contest.users.filter(virtual=0)
|
||||
.prefetch_related('user__organizations')
|
||||
.annotate(username=F('user__user__username'))
|
||||
.order_by('-score', 'cumtime') if can_see_rankings else [])
|
||||
|
@ -134,16 +134,15 @@ def api_v1_user_info(request, user):
|
|||
last_rating = profile.ratings.last()
|
||||
|
||||
contest_history = {}
|
||||
if not profile.is_unlisted:
|
||||
participations = ContestParticipation.objects.filter(user=profile, virtual=0, contest__is_visible=True,
|
||||
contest__is_private=False,
|
||||
contest__is_organization_private=False)
|
||||
for contest_key, rating, volatility in participations.values_list('contest__key', 'rating__rating',
|
||||
'rating__volatility'):
|
||||
contest_history[contest_key] = {
|
||||
'rating': rating,
|
||||
'volatility': volatility,
|
||||
}
|
||||
participations = ContestParticipation.objects.filter(user=profile, virtual=0, contest__is_visible=True,
|
||||
contest__is_private=False,
|
||||
contest__is_organization_private=False)
|
||||
for contest_key, rating, volatility in participations.values_list('contest__key', 'rating__rating',
|
||||
'rating__volatility'):
|
||||
contest_history[contest_key] = {
|
||||
'rating': rating,
|
||||
'volatility': volatility,
|
||||
}
|
||||
|
||||
resp['contests'] = {
|
||||
'current_rating': last_rating.rating if last_rating else None,
|
||||
|
|
|
@ -591,7 +591,7 @@ class ContestStats(TitleMixin, ContestMixin, DetailView):
|
|||
|
||||
ContestRankingProfile = namedtuple(
|
||||
'ContestRankingProfile',
|
||||
'id user css_class username points cumtime organization participation '
|
||||
'id user css_class username points cumtime tiebreaker organization participation '
|
||||
'participation_rating problem_cells result_cell',
|
||||
)
|
||||
|
||||
|
@ -607,6 +607,7 @@ def make_contest_ranking_profile(contest, participation, contest_problems):
|
|||
username=user.username,
|
||||
points=participation.score,
|
||||
cumtime=participation.cumtime,
|
||||
tiebreaker=participation.tiebreaker,
|
||||
organization=user.organization,
|
||||
participation_rating=participation.rating.rating if hasattr(participation, 'rating') else None,
|
||||
problem_cells=[contest.format.display_user_problem(participation, contest_problem)
|
||||
|
@ -622,17 +623,17 @@ def base_contest_ranking_list(contest, problems, queryset):
|
|||
|
||||
|
||||
def contest_ranking_list(contest, problems):
|
||||
return base_contest_ranking_list(contest, problems, contest.users.filter(virtual=0, user__is_unlisted=False)
|
||||
return base_contest_ranking_list(contest, problems, contest.users.filter(virtual=0)
|
||||
.prefetch_related('user__organizations')
|
||||
.extra(select={'round_score': 'round(score, 6)'})
|
||||
.order_by('is_disqualified', '-round_score', 'cumtime'))
|
||||
.order_by('is_disqualified', '-round_score', 'cumtime', 'tiebreaker'))
|
||||
|
||||
|
||||
def get_contest_ranking_list(request, contest, participation=None, ranking_list=contest_ranking_list,
|
||||
show_current_virtual=True, ranker=ranker):
|
||||
problems = list(contest.contest_problems.select_related('problem').defer('problem__description').order_by('order'))
|
||||
|
||||
users = ranker(ranking_list(contest, problems), key=attrgetter('points', 'cumtime'))
|
||||
users = ranker(ranking_list(contest, problems), key=attrgetter('points', 'cumtime', 'tiebreaker'))
|
||||
|
||||
if show_current_virtual:
|
||||
if participation is None and request.user.is_authenticated:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue