From 08bd60e27501b740e1426a299507769610c2a7c5 Mon Sep 17 00:00:00 2001 From: idanstark42 Date: Mon, 10 Feb 2020 19:05:52 +0200 Subject: [PATCH 1/3] Update tournament_status_logic.js --- server/logic/tournament_status_logic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/logic/tournament_status_logic.js b/server/logic/tournament_status_logic.js index b6a41db..5a8d78a 100644 --- a/server/logic/tournament_status_logic.js +++ b/server/logic/tournament_status_logic.js @@ -65,7 +65,7 @@ function resetMatchNumberByStage () { .then(currStage => getFirstMatchInStage(currStage)) .then(match => { MsLogger.info(`Resetting current match number to ${match}`) - return setCurrentMatchNumber(match.matchId) + return setCurrentMatchNumber(match.matchId - 1) }) .catch(e => { MsLogger.error(e.message) From b575c802b23c2a0f20f48ba8ef87636132a3a28b Mon Sep 17 00:00:00 2001 From: idanstark42 Date: Sat, 22 Feb 2020 21:56:06 +0200 Subject: [PATCH 2/3] Now this should work --- server/logic/tournament_status_logic.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/logic/tournament_status_logic.js b/server/logic/tournament_status_logic.js index 5a8d78a..d95a918 100644 --- a/server/logic/tournament_status_logic.js +++ b/server/logic/tournament_status_logic.js @@ -140,8 +140,12 @@ function getCurrentMatchNumber () { } function setCurrentMatchNumber (newMatch) { - return isMatchInCurrentStage(newMatch).then(result => { - if (result || newMatch === 0) { + return Promise.all([ + isMatchInCurrentStage(newMatch), + getSetting(CURRENT_STAGE_NAME) + .then(currStage => getFirstMatchInStage(currStage)) + ]).then(([matchInCurrentStage, firstMatchInCurrentStage]) => { + if (matchInCurrentStage || newMatch === firstMatchInCurrentStage - 1) { return updateSetting(CURRENT_MATCH_NAME, newMatch).then(() => { publishMatchAvailable() return true From 284310229f5b8074f27057b2dbdaed63f7630f5b Mon Sep 17 00:00:00 2001 From: idanstark42 Date: Mon, 2 Mar 2020 16:51:07 +0200 Subject: [PATCH 3/3] Fixed check --- server/logic/tournament_status_logic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/logic/tournament_status_logic.js b/server/logic/tournament_status_logic.js index d95a918..909b225 100644 --- a/server/logic/tournament_status_logic.js +++ b/server/logic/tournament_status_logic.js @@ -145,7 +145,7 @@ function setCurrentMatchNumber (newMatch) { getSetting(CURRENT_STAGE_NAME) .then(currStage => getFirstMatchInStage(currStage)) ]).then(([matchInCurrentStage, firstMatchInCurrentStage]) => { - if (matchInCurrentStage || newMatch === firstMatchInCurrentStage - 1) { + if (matchInCurrentStage || newMatch === firstMatchInCurrentStage.matchId - 1) { return updateSetting(CURRENT_MATCH_NAME, newMatch).then(() => { publishMatchAvailable() return true