Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
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
Taiko Web
Commits
080c0c7e
Commit
080c0c7e
authored
Jul 02, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrator of rainbow crown
parent
5fad76eb
Pipeline
#229
passed with stages
in 1 minute and 6 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
477 additions
and
0 deletions
+477
-0
.dockerignore
.dockerignore
+3
-0
.gitignore
.gitignore
+3
-0
tools/migrate-rainbow-crown/package-lock.json
tools/migrate-rainbow-crown/package-lock.json
+362
-0
tools/migrate-rainbow-crown/package.json
tools/migrate-rainbow-crown/package.json
+23
-0
tools/migrate-rainbow-crown/run.ts
tools/migrate-rainbow-crown/run.ts
+72
-0
tools/migrate-rainbow-crown/tsconfig.json
tools/migrate-rainbow-crown/tsconfig.json
+14
-0
No files found.
.dockerignore
View file @
080c0c7e
...
@@ -55,3 +55,6 @@ public/assets/song_skins
...
@@ -55,3 +55,6 @@ public/assets/song_skins
.venv*
.venv*
app.pyc
app.pyc
.vscode
.vscode
node_modules
build
.gitignore
View file @
080c0c7e
...
@@ -55,3 +55,6 @@ public/assets/song_skins
...
@@ -55,3 +55,6 @@ public/assets/song_skins
.venv*
.venv*
app.pyc
app.pyc
.vscode
.vscode
node_modules
build
tools/migrate-rainbow-crown/package-lock.json
0 → 100644
View file @
080c0c7e
This diff is collapsed.
Click to expand it.
tools/migrate-rainbow-crown/package.json
0 → 100644
View file @
080c0c7e
{
"name"
:
"migrate-rainbow-crown"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"build/run.js"
,
"scripts"
:
{
"build"
:
"./node_modules/.bin/tsc"
,
"start"
:
"node build/run.js"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"https://code.mycard.moe/nanahira/taiko-web"
},
"author"
:
"Nanahira"
,
"license"
:
"AGPL-3.0"
,
"dependencies"
:
{
"@types/node"
:
"^14.0.14"
,
"@types/underscore"
:
"^1.10.2"
,
"then-mongo"
:
"^3.1.0"
,
"typescript"
:
"^3.9.6"
,
"underscore"
:
"^1.10.2"
}
}
tools/migrate-rainbow-crown/run.ts
0 → 100644
View file @
080c0c7e
import
mongo
,
{
Database
,
Collection
}
from
"
then-mongo
"
;
const
scoreKeys
=
[
"
points
"
,
"
good
"
,
"
ok
"
,
"
bad
"
,
"
maxCombo
"
,
"
drumroll
"
];
class
Score
{
original
:
string
;
available
:
boolean
;
crown
:
number
;
points
:
number
;
good
:
number
;
ok
:
number
;
bad
:
number
;
maxCombo
:
number
;
drumroll
:
number
;
constructor
(
str
:
string
)
{
this
.
original
=
str
;
if
(
!
str
.
length
)
{
this
.
available
=
false
;
return
;
}
this
.
available
=
true
;
this
.
crown
=
parseInt
(
str
.
slice
(
0
,
1
));
const
components
=
str
.
slice
(
1
).
split
(
"
,
"
);
for
(
let
i
=
0
;
i
<
components
.
length
;
++
i
)
{
this
[
scoreKeys
[
i
]]
=
parseInt
(
components
[
i
],
36
);
}
}
toString
()
{
if
(
!
this
.
available
)
{
return
""
;
}
const
components
=
scoreKeys
.
map
(
key
=>
{
return
this
[
key
].
toString
(
36
);
});
return
`
${
this
.
crown
}${
components
.
join
(
"
,
"
)}
`
;
}
}
function
replaceString
(
src
:
string
)
{
const
diffs
=
src
.
split
(
"
;
"
).
map
(
m
=>
new
Score
(
m
));
for
(
let
score
of
diffs
)
{
if
(
score
.
crown
===
2
&&
score
.
ok
===
0
)
{
score
.
crown
=
3
;
}
}
return
diffs
.
map
(
s
=>
s
.
toString
()).
join
(
"
;
"
);
}
//console.log(replaceString("2imnw,4h,0,0,4h,k"));
const
mongoUrl
=
process
.
argv
[
2
];
let
col
:
Collection
;
async
function
updateOne
(
scoreRow
:
any
)
{
const
str
=
scoreRow
.
score
;
const
newStr
=
replaceString
(
str
);
if
(
str
!==
newStr
)
{
await
col
.
update
({
_id
:
scoreRow
.
_id
},
{
$set
:
{
score
:
newStr
}
});
console
.
log
(
`Score of
${
scoreRow
.
username
}
${
scoreRow
.
hash
}
updated from
${
str
}
to
${
newStr
}
.`
);
}
}
async
function
main
()
{
console
.
log
(
"
Started.
"
);
const
db
=
mongo
(
mongoUrl
);
col
=
db
.
collection
(
"
scores
"
);
console
.
log
(
"
Checking scores.
"
);
await
col
.
find
().
map
(
updateOne
);
console
.
log
(
"
Finished.
"
);
process
.
exit
();
}
main
();
tools/migrate-rainbow-crown/tsconfig.json
0 → 100644
View file @
080c0c7e
{
"compilerOptions"
:
{
"outDir"
:
"build"
,
"module"
:
"commonjs"
,
"target"
:
"esnext"
,
"esModuleInterop"
:
true
,
"sourceMap"
:
true
},
"compileOnSave"
:
true
,
"allowJs"
:
true
,
"include"
:
[
"*.ts"
]
}
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