Commit 53fc7f5f authored by nanahira's avatar nanahira

retry

parent 4fe11288
Pipeline #2298 passed with stages
in 29 seconds
...@@ -58,15 +58,18 @@ async function checkQuit(round: number, oldPlayerId: number) { ...@@ -58,15 +58,18 @@ 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}.`);
while (true) {
try { try {
await axios.delete(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/participants/${newPlayerId}.json?api_key=${encodeURIComponent(config.apiKey)}`, { await axios.delete(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/participants/${newPlayerId}.json?api_key=${encodeURIComponent(config.apiKey)}`, {
responseType: 'json' responseType: 'json'
}); });
console.log(`Successfully quitted player ${oldPlayer.name} in round ${round}.`); console.log(`Successfully quitted player ${oldPlayer.name} in round ${round}.`);
break;
} catch (e) { } catch (e) {
console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`); console.log(`Failed quitting player ${oldPlayer.name} in round ${round}: ${e.toString()}`);
} }
} }
}
} }
async function migrateMatch(match: Match) { async function migrateMatch(match: Match) {
...@@ -98,6 +101,7 @@ async function migrateMatch(match: Match) { ...@@ -98,6 +101,7 @@ 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)));
while (true) {
try { try {
await axios.put(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/matches/${match.id}.json`, { await axios.put(`https://api.challonge.com/v1/tournaments/${config.targetTournament}/matches/${match.id}.json`, {
api_key: config.apiKey, api_key: config.apiKey,
...@@ -107,11 +111,11 @@ async function migrateMatch(match: Match) { ...@@ -107,11 +111,11 @@ async function migrateMatch(match: Match) {
} }
}, axiosPostConfig); }, axiosPostConfig);
console.log(`Successfully migrated match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}.`); console.log(`Successfully migrated match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}.`);
break;
} catch (e) { } catch (e) {
console.error(`Failed migrating match ${currentMatchPlayer1Name} vs ${currentMatchPlayer2Name}: ${e.toString()}`); 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