mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 23:58:24 +02:00
Split 5-teams pols in two pools for each room
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -361,6 +361,17 @@ class Pool(models.Model):
|
||||
.prefetch_related('participation')])
|
||||
await self.asave()
|
||||
|
||||
pool2 = None
|
||||
if self.size == 5:
|
||||
pool2, _created = await PPool.objects.aget_or_create(
|
||||
tournament=self.round.draw.tournament,
|
||||
round=self.round.number,
|
||||
letter=self.letter,
|
||||
room=2,
|
||||
)
|
||||
await pool2.participations.aset([td.participation async for td in self.team_draws
|
||||
.prefetch_related('participation')])
|
||||
|
||||
# Define the passage matrix according to the number of teams
|
||||
table = []
|
||||
if self.size == 3:
|
||||
@ -380,16 +391,24 @@ class Pool(models.Model):
|
||||
table = [
|
||||
[0, 2, 3],
|
||||
[1, 3, 4],
|
||||
[4, 0, 2],
|
||||
[2, 4, 0],
|
||||
[3, 0, 1],
|
||||
[4, 1, 2],
|
||||
]
|
||||
|
||||
for i, line in enumerate(table):
|
||||
passage_pool = self.associated_pool
|
||||
passage_position = i + 1
|
||||
if self.size == 5:
|
||||
# In 5-teams pools, we may create some passages in the second room
|
||||
if i % 2 == 1:
|
||||
passage_pool = pool2
|
||||
passage_position = 1 + i // 2
|
||||
|
||||
# Create the passage
|
||||
await Passage.objects.acreate(
|
||||
pool=self.associated_pool,
|
||||
position=i + 1,
|
||||
pool=passage_pool,
|
||||
position=passage_position,
|
||||
solution_number=tds[line[0]].accepted,
|
||||
defender=tds[line[0]].participation,
|
||||
opponent=tds[line[1]].participation,
|
||||
|
Reference in New Issue
Block a user