From f8d6d77704dc20d760b752f2b7060e65a1cb3ea3 Mon Sep 17 00:00:00 2001 From: Erik Vroon Date: Mon, 28 Oct 2024 08:23:11 +0100 Subject: [PATCH] Show stage item input options correctly (#971) --- backend/bracket/logic/ranking/elo.py | 1 - frontend/src/components/builder/builder.tsx | 43 +++++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/backend/bracket/logic/ranking/elo.py b/backend/bracket/logic/ranking/elo.py index c3c20a21..668d8896 100644 --- a/backend/bracket/logic/ranking/elo.py +++ b/backend/bracket/logic/ranking/elo.py @@ -80,7 +80,6 @@ def determine_ranking_for_stage_item( if not round_.is_draft for match in round_.matches if isinstance(match, MatchWithDetailsDefinitive) - if match.stage_item_input1_score != 0 or match.stage_item_input2_score != 0 ] for match in matches: for team_index, stage_item_input in enumerate(match.stage_item_inputs): diff --git a/frontend/src/components/builder/builder.tsx b/frontend/src/components/builder/builder.tsx index 7329cbb8..59600332 100644 --- a/frontend/src/components/builder/builder.tsx +++ b/frontend/src/components/builder/builder.tsx @@ -155,31 +155,31 @@ export function getAvailableInputs( stageItemMap: any ) { const getComboBoxOptionForStageItemInput = (option: StageItemInputOption) => { - if (option.winner_from_stage_item_id == null) { - if (option.team_id == null) return null; - const team = teamsMap[option.team_id]; - if (team == null) return null; - assert(option.team_id === team.id); + if (option.winner_from_stage_item_id != null) { + assert(option.winner_position != null); + const stageItem = stageItemMap[option.winner_from_stage_item_id]; + + if (stageItem == null) return null; return { - value: `${option.team_id}`, - label: team.name, - team_id: team.id, - winner_from_stage_item_id: null, - winner_position: null, + value: `${option.winner_from_stage_item_id}_${option.winner_position}`, + label: `${formatStageItemInput(option.winner_position, stageItem.name)}`, + team_id: null, + winner_from_stage_item_id: option.winner_from_stage_item_id, + winner_position: option.winner_position, already_taken: option.already_taken, }; } - assert(option.winner_position != null); - const stageItem = stageItemMap[option.winner_from_stage_item_id]; - - if (stageItem == null) return null; + if (option.team_id == null) return null; + const team = teamsMap[option.team_id]; + if (team == null) return null; + assert(option.team_id === team.id); return { - value: `${option.winner_from_stage_item_id}_${option.winner_position}`, - label: `${formatStageItemInput(option.winner_position, stageItem.name)}`, - team_id: null, - winner_from_stage_item_id: option.winner_from_stage_item_id, - winner_position: option.winner_position, + value: `${option.team_id}`, + label: team.name, + team_id: team.id, + winner_from_stage_item_id: null, + winner_position: null, already_taken: option.already_taken, }; }; @@ -249,10 +249,11 @@ function StageItemRow({ .sort((i1, i2) => (i1.slot > i2.slot ? 1 : -1)) .map((input, i) => { let currentOptionValue = null; + if (input.winner_from_stage_item_id != null) { + currentOptionValue = `${input.winner_from_stage_item_id}_${input.winner_position}`; + } else if (input.team_id != null) { currentOptionValue = `${input.team_id}`; - } else if (input.winner_from_stage_item_id != null) { - currentOptionValue = `${input.winner_from_stage_item_id}_${input.winner_position}`; } return (