Add virtual participation to ranking list when virtual joining
This commit is contained in:
parent
dc86e3a095
commit
308006f7bd
2 changed files with 20 additions and 15 deletions
|
@ -1107,7 +1107,6 @@ def get_contest_ranking_list(
|
||||||
contest,
|
contest,
|
||||||
participation=None,
|
participation=None,
|
||||||
ranking_list=contest_ranking_list,
|
ranking_list=contest_ranking_list,
|
||||||
show_current_virtual=False,
|
|
||||||
ranker=ranker,
|
ranker=ranker,
|
||||||
show_final=False,
|
show_final=False,
|
||||||
):
|
):
|
||||||
|
@ -1117,21 +1116,26 @@ def get_contest_ranking_list(
|
||||||
.order_by("order")
|
.order_by("order")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set participation to current virtual join if it's None
|
||||||
|
ranking_participation = None
|
||||||
|
if participation is None and request.user.is_authenticated:
|
||||||
|
participation = request.profile.current_contest
|
||||||
|
if participation is None or participation.contest_id != contest.id:
|
||||||
|
participation = None
|
||||||
|
if participation is not None and participation.virtual:
|
||||||
|
ranking_participation = make_contest_ranking_profile(
|
||||||
|
contest, participation, problems
|
||||||
|
)
|
||||||
|
|
||||||
|
ranking_list_result = ranking_list(contest, problems, show_final=show_final)
|
||||||
|
|
||||||
|
if ranking_participation and ranking_participation not in ranking_list_result:
|
||||||
|
ranking_list_result.append(ranking_participation)
|
||||||
|
|
||||||
users = ranker(
|
users = ranker(
|
||||||
ranking_list(contest, problems, show_final=show_final),
|
ranking_list_result,
|
||||||
key=attrgetter("points", "cumtime", "tiebreaker"),
|
key=attrgetter("points", "cumtime", "tiebreaker"),
|
||||||
)
|
)
|
||||||
|
|
||||||
if show_current_virtual:
|
|
||||||
if participation is None and request.user.is_authenticated:
|
|
||||||
participation = request.profile.current_contest
|
|
||||||
if participation is None or participation.contest_id != contest.id:
|
|
||||||
participation = None
|
|
||||||
if participation is not None and participation.virtual:
|
|
||||||
users = chain(
|
|
||||||
[("-", make_contest_ranking_profile(contest, participation, problems))],
|
|
||||||
users,
|
|
||||||
)
|
|
||||||
return users, problems
|
return users, problems
|
||||||
|
|
||||||
|
|
||||||
|
@ -1272,7 +1276,6 @@ class ContestParticipationList(LoginRequiredMixin, ContestRankingBase):
|
||||||
return get_contest_ranking_list(
|
return get_contest_ranking_list(
|
||||||
self.request,
|
self.request,
|
||||||
self.object,
|
self.object,
|
||||||
show_current_virtual=False,
|
|
||||||
ranking_list=partial(base_contest_ranking_list, queryset=queryset),
|
ranking_list=partial(base_contest_ranking_list, queryset=queryset),
|
||||||
ranker=lambda users, key: (
|
ranker=lambda users, key: (
|
||||||
(user.participation.virtual or live_link, user) for user in users
|
(user.participation.virtual or live_link, user) for user in users
|
||||||
|
|
|
@ -203,7 +203,9 @@ class UserAboutPage(UserPage):
|
||||||
"label": rating.contest.name,
|
"label": rating.contest.name,
|
||||||
"rating": rating.rating,
|
"rating": rating.rating,
|
||||||
"ranking": rating.rank,
|
"ranking": rating.rank,
|
||||||
"link": reverse("contest_ranking", args=(rating.contest.key,)),
|
"link": reverse("contest_ranking", args=(rating.contest.key,))
|
||||||
|
+ "#!"
|
||||||
|
+ self.object.username,
|
||||||
"timestamp": (rating.contest.end_time - EPOCH).total_seconds()
|
"timestamp": (rating.contest.end_time - EPOCH).total_seconds()
|
||||||
* 1000,
|
* 1000,
|
||||||
"date": date_format(
|
"date": date_format(
|
||||||
|
|
Loading…
Reference in a new issue