Commit 53fc7f5f authored by nanahira's avatar nanahira

retry

parent 4fe11288
Pipeline #2298 passed with stages
in 29 seconds
......@@ -58,13 +58,16 @@ async function checkQuit(round: number, oldPlayerId: number) {
if (!nextRoundMatch) {
const newPlayerId = newParticipantNameMap.get(oldPlayer.name).id;
console.log(`Player ${oldPlayer.name}: ${oldPlayerId}/${newPlayerId} quitted in round ${round}.`);
try {
await axios.delete(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/participants/${newPlayerId}.json?api_key=${encodeURIComponent(config.apiKey)}`, {
responseType: 'json'
});
console.log(`Successfully quitted player ${oldPlayer.name} in round ${round}.`);
} catch (e) {
console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`);
while (true) {
try {
await axios.delete(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/participants/${newPlayerId}.json?api_key=${encodeURIComponent(config.apiKey)}`, {
responseType: 'json'
});
console.log(`Successfully quitted player ${oldPlayer.name} in round ${round}.`);
break;
} catch (e) {
console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`);
}
}
}
}
......@@ -98,20 +101,21 @@ async function migrateMatch(match: Match) {
}
const oldPlayerIds = [oldMatch.player1_id, oldMatch.player2_id]
await Promise.all(oldPlayerIds.map(pid => checkQuit(match.round, pid)));
try {
await axios.put(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/matches/${match.id}.json`, {
api_key: config.apiKey,
match: {
scores_csv: oldMatch.scores_csv,
winner_id
}
}, axiosPostConfig);
console.log(`Successfully migrated match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}.`);
} catch (e) {
console.error(`Failed migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}: ${e.toString()}`);
while (true) {
try {
await axios.put(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/matches/${match.id}.json`, {
api_key: config.apiKey,
match: {
scores_csv: oldMatch.scores_csv,
winner_id
}
}, axiosPostConfig);
console.log(`Successfully migrated match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}.`);
break;
} catch (e) {
console.error(`Failed migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}: ${e.toString()}`);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment