Skip to content
Snippets Groups Projects
Commit cb15a3b2 authored by Martin Mareš's avatar Martin Mareš
Browse files

ScoreResult říká, zda se zobrazuje pořadí

Předtím se o zobrazování pořadí rozhodovalo lokálně na několika místech.
parent 898179c0
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !118. Comments created here will be created in the context of that merge request.
......@@ -96,9 +96,9 @@ def handle_snapshot_score(the_job: TheJob):
snapshot_rows = []
for result in results:
order: Optional[dict] = None
if result.successful or not score.want_successful:
if result.show_order:
order = result.order.__dict__
snapshot_row = {
snapshot_row: Dict[str, Any] = {
'order': order,
'winner': result.winner,
'successful': result.successful,
......
......@@ -49,6 +49,7 @@ class ScoreResult:
self.order = ScoreResult._null_score_order
self.winner = False
self.successful = False
self.show_order = True
self._order_key = []
def get_sols(self) -> List[db.Solution]:
......@@ -232,6 +233,8 @@ class Score:
total_points = result.get_total_points()
result.winner = self.want_winners and total_points >= self.round.score_winner_limit
result.successful = self.want_successful and total_points >= self.round.score_successful_limit
if self.want_successful and not result.successful:
result.show_order = False
def _load_prev_round(self, step: int) -> bool:
"""Načtení úloh a řešení předchozího kola, pokud takové existuje."""
......@@ -375,11 +378,12 @@ class Score:
points_from_max = list(sorted(sol_points.values()))
points_from_difficult = [sol_points[task_id] for task_id in tasks_by_difficulty]
if result.successful or not self.want_successful:
if result.show_order:
# Primárně podle počtu získaných bodů, sekundárně podle bodů od maxima, terciárně podle bodů od nejobtížnější
result._order_key.append((total_points, points_from_max, points_from_difficult))
else:
# Neúspěšné řešitele třídíme podle počtu získaných bodů, sekundárně podle jména, jednoznačně podle user_id
# Neúspěšné řešitele bez uvedeného pořadí třídíme podle počtu získaných bodů, sekundárně podle jména,
# jednoznačně podle user_id
result._order_key.append((total_points, result.user.name_sort_key(), result.user.user_id))
# Otestujeme, jestli teď existují sdílená místa
......
......@@ -183,7 +183,7 @@ def org_score(round_id: Optional[int] = None, hier_id: Optional[int] = None, ct_
local_pion_ct_id = subcontest_id_map[(round.round_id, pion.contest_id)]
order_cell: Union[Cell, str]
if result.successful or not score.want_successful:
if result.show_order:
order_cell = OrderCell(result.order.place, result.order.span, result.order.continuation)
else:
order_cell = ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment