Minor bugfix
This commit is contained in:
parent
9f58f902b8
commit
eb70ef67b5
|
@ -165,23 +165,19 @@ async function setMatchWinner(matchId, winnerId) {
|
||||||
async function unsetContestantAndWinner(matchId, teamId) {
|
async function unsetContestantAndWinner(matchId, teamId) {
|
||||||
let match = await getMatch(matchId);
|
let match = await getMatch(matchId);
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
unsetContestant(matchId, teamId)
|
// Find what the child match that supplied the team
|
||||||
.then(() => {
|
connection.query("SELECT * FROM matches WHERE parentMatchId = ? AND winnerId = ?", [matchId, teamId], (err, childMatches) => {
|
||||||
// Find what the child match that supplied the team
|
if (err) { console.log(err); reject(err); }
|
||||||
connection.query("SELECT * FROM matches WHERE parentMatchId = ? AND winnerId = ?", [matchId, teamId], (err, childMatches) => {
|
if (childMatches.length != 1) {
|
||||||
if (err) { console.log(err); reject(err); }
|
reject("Error: Could not find the correct child match");
|
||||||
if (childMatches.length != 1) {
|
return;
|
||||||
reject("Error: Could not find the correct child match");
|
}
|
||||||
return;
|
let childMatch = childMatches[0];
|
||||||
}
|
// Remove the winner from the child match
|
||||||
let childMatch = childMatches[0];
|
setMatchWinner(childMatch.id, null)
|
||||||
// Remove the winner from the child match
|
.then(() => { resolve(); })
|
||||||
setMatchWinner(childMatch.id, null)
|
.catch(err => { reject(err); });
|
||||||
.then(() => { resolve(); })
|
});
|
||||||
.catch(err => { reject(err); });
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(err => { reject(err); });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue