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

Postup z minulého kola počítá s dělenými koly

Pro vybírání minulého kola bere jen master kolo, úlohy pro počítání bodů
vybíráme z celé skupiny kol.

Issue #178
parent 7c24a7ec
Branches
No related tags found
1 merge request!48Dělená kola napotřetí
This commit is part of merge request !36. Comments created here will be created in the context of that merge request.
...@@ -1413,11 +1413,14 @@ def org_contest_advance(contest_id: int): ...@@ -1413,11 +1413,14 @@ def org_contest_advance(contest_id: int):
flash('Aktuální kolo není ve stavu přípravy', 'danger') flash('Aktuální kolo není ve stavu přípravy', 'danger')
return redirect_back() return redirect_back()
prev_round = sess.query(db.Round).filter_by(year=round.year, category=round.category, seq=round.seq - 1).one_or_none() prev_round = sess.query(db.Round).filter_by(
year=round.year, category=round.category, seq=round.seq - 1
).filter(db.Round.master_round_id == db.Round.round_id).one_or_none()
if prev_round is None: if prev_round is None:
flash('Předchozí kolo nenalezeno', 'danger') flash('Předchozí kolo nenalezeno', 'danger')
return redirect_back() return redirect_back()
elif prev_round.state != db.RoundState.closed: elif prev_round.state != db.RoundState.closed:
# FIXME: Možná kontrolovat stav uzavření všech kol ve skupině kol?
flash('Předchozí kolo dosud nebylo ukončeno', 'danger') flash('Předchozí kolo dosud nebylo ukončeno', 'danger')
return redirect_back() return redirect_back()
elif prev_round.level < round.level: elif prev_round.level < round.level:
...@@ -1449,7 +1452,8 @@ def org_contest_advance(contest_id: int): ...@@ -1449,7 +1452,8 @@ def org_contest_advance(contest_id: int):
if form.boundary.data > 0: if form.boundary.data > 0:
accept_uids = (sess.query(db.Solution.user_id) accept_uids = (sess.query(db.Solution.user_id)
.select_from(db.Solution) .select_from(db.Solution)
.join(db.Task, and_(db.Task.task_id == db.Solution.task_id, db.Task.round == prev_round)) # Vybíráme úlohy, jejich round patří do stejné skupiny kol jako prev_round
.join(db.Task, and_(db.Task.task_id == db.Solution.task_id, db.Task.round.master_round_id == prev_round.round_id))
.filter(db.Solution.user_id.in_(prev_pion_query.with_entities(db.Participation.user_id).subquery())) .filter(db.Solution.user_id.in_(prev_pion_query.with_entities(db.Participation.user_id).subquery()))
.group_by(db.Solution.user_id) .group_by(db.Solution.user_id)
.having(func.sum(db.Solution.points) >= form.boundary.data) .having(func.sum(db.Solution.points) >= form.boundary.data)
...@@ -1460,10 +1464,10 @@ def org_contest_advance(contest_id: int): ...@@ -1460,10 +1464,10 @@ def org_contest_advance(contest_id: int):
want_execute = form.execute.data want_execute = form.execute.data
if want_execute: if want_execute:
app.logger.info(f'Postup: Z kola #{prev_round.round_id} do #{round.round_id}, soutěž #{contest_id}') app.logger.info(f'Postup: Z kola #{prev_round.round_id} do #{round.master_round_id}, soutěž #{master_contest.contest_id}')
mo.util.log( mo.util.log(
type=db.LogType.contest, type=db.LogType.contest,
what=contest_id, what=master_contest.contest_id,
details={'action': 'advance'}, details={'action': 'advance'},
) )
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment