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) { ...@@ -58,13 +58,16 @@ async function checkQuit(round: number, oldPlayerId: number) {
if (!nextRoundMatch) { if (!nextRoundMatch) {
const newPlayerId = newParticipantNameMap.get(oldPlayer.name).id; const newPlayerId = newParticipantNameMap.get(oldPlayer.name).id;
console.log(`Player ${oldPlayer.name}: ${oldPlayerId}/${newPlayerId} quitted in round ${round}.`); console.log(`Player ${oldPlayer.name}: ${oldPlayerId}/${newPlayerId} quitted in round ${round}.`);
try { while (true) {
await axios.delete(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/participants/${newPlayerId}.json?api_key=${encodeURIComponent(config.apiKey)}`, { try {
responseType: 'json' 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(`Successfully quitted player ${oldPlayer.name} in round ${round}.`);
console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`); break;
} catch (e) {
console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`);
}
} }
} }
} }
...@@ -98,20 +101,21 @@ async function migrateMatch(match: Match) { ...@@ -98,20 +101,21 @@ async function migrateMatch(match: Match) {
} }
const oldPlayerIds = [oldMatch.player1_id, oldMatch.player2_id] const oldPlayerIds = [oldMatch.player1_id, oldMatch.player2_id]
await Promise.all(oldPlayerIds.map(pid => checkQuit(match.round, pid))); await Promise.all(oldPlayerIds.map(pid => checkQuit(match.round, pid)));
try { while (true) {
await axios.put(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/matches/${match.id}.json`, { try {
api_key: config.apiKey, await axios.put(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/matches/${match.id}.json`, {
match: { api_key: config.apiKey,
scores_csv: oldMatch.scores_csv, match: {
winner_id scores_csv: oldMatch.scores_csv,
} winner_id
}, axiosPostConfig); }
console.log(`Successfully migrated match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}.`); }, axiosPostConfig);
} catch (e) { console.log(`Successfully migrated match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}.`);
console.error(`Failed migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}: ${e.toString()}`); 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