Skip to content
Snippets Groups Projects
Commit 8daec4ca authored by Jiří Setnička's avatar Jiří Setnička
Browse files

DB a Score: Přidání score_suborder do tabulky participations a třídění podle něj

Issue #210
parent c1792eda
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !105. Comments created here will be created in the context of that merge request.
......@@ -177,6 +177,7 @@ CREATE TABLE participations (
contest_id int NOT NULL REFERENCES contests(contest_id),
place_id int NOT NULL REFERENCES places(place_id), -- konkrétní soutěžní místo (default: region contestu)
state part_state NOT NULL,
score_suborder int DEFAULT NULL,
PRIMARY KEY (user_id, contest_id)
);
......
SET ROLE 'mo_osmo';
ALTER TABLE participations ADD COLUMN
score_suborder int DEFAULT NULL;
......@@ -494,6 +494,7 @@ class Participation(Base):
contest_id = Column(Integer, ForeignKey('contests.contest_id'), primary_key=True, nullable=False)
place_id = Column(Integer, ForeignKey('places.place_id'), nullable=False)
state = Column(Enum(PartState, name='part_state'), nullable=False)
score_suborder = Column(Integer, nullable=True)
contest = relationship('Contest', primaryjoin='Participation.contest_id == Contest.contest_id')
place = relationship('Place', primaryjoin='Participation.place_id == Place.place_id')
......
......@@ -273,7 +273,7 @@ class Score:
if self.round.score_mode == db.RoundScoreMode.basic:
# Základní mód - jen podle celkových bodů, se sdílenými místy
for result in self._results.values():
result._order_key = [-result.get_total_points()]
result._order_key = [-result.get_total_points(), result.pion.score_suborder or 0]
elif self.round.score_mode == db.RoundScoreMode.mo:
self._add_mo_order_key()
......@@ -382,7 +382,7 @@ class Score:
# Pokud jsme našli stejný klíč, opakujeme cyklus s minulým kolem
step += 1
# Na konec třídícího klíče přidáme ročník (menší ročník první)
# Na konec třídícího klíče přidáme ročník (menší ročník první) a dotřiďovací klíč
for result in self._results.values():
grade = normalize_grade(result.pant.grade)
if grade == -1:
......@@ -391,6 +391,7 @@ class Score:
f"Účastník {result.user.first_name} {result.user.last_name} má neplatný ročník {result.pant.grade}"
)
result._order_key.append(grade)
result._order_key.append(result.pion.score_suborder or 0)
if self._exists_same_order_key():
self._add_message(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment