Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
challonge-migrator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
challonge-migrator
Commits
53fc7f5f
Commit
53fc7f5f
authored
Jan 31, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
retry
parent
4fe11288
Pipeline
#2298
passed with stages
in 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
20 deletions
+24
-20
migrate.ts
migrate.ts
+24
-20
No files found.
migrate.ts
View file @
53fc7f5f
...
...
@@ -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
()}
`
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment