Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-cn-database-generator
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
MyCard
ygopro-cn-database-generator
Commits
ed9b1707
Commit
ed9b1707
authored
Oct 08, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small changes
parent
2ecf71fc
Pipeline
#892
passed with stages
in 2 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
src/dbreader.ts
src/dbreader.ts
+14
-3
No files found.
src/dbreader.ts
View file @
ed9b1707
...
...
@@ -70,21 +70,32 @@ export class DBReader extends Base {
await
this
.
outputdb
.
run
(
sql
);
}
}
async
getCodeFromJapaneseName
(
name
:
string
):
Promise
<
number
[]
>
{
async
getCodeFromJapaneseName
(
name
:
string
):
Promise
<
number
>
{
this
.
log
.
debug
(
`Reading JP database for code of name
${
name
}
.`
);
const
output
=
await
this
.
jpdb
.
get
(
'
SELECT id FROM texts WHERE name = ?
'
,
name
);
if
(
!
output
)
{
this
.
log
.
debug
(
`Code of
${
name
}
not found.`
);
return
[]
;
return
0
;
}
const
code
:
number
=
output
.
id
;
return
code
;
}
async
getExtendedCodeFromJapaneseName
(
name
:
string
):
Promise
<
number
[]
>
{
const
code
:
number
=
await
this
.
getCodeFromJapaneseName
(
name
);
if
(
!
code
)
{
return
[];
}
this
.
log
.
debug
(
`Reading CN database for more codes of id
${
code
}
.`
);
const
moreCodes
:
number
[]
=
(
await
this
.
cndb
.
all
(
'
SELECT id FROM datas WHERE id >= ? AND id <= ?
'
,
[
code
,
code
+
10
])).
map
(
m
=>
m
.
id
);
this
.
log
.
debug
(
`
${
name
}
=>
${
moreCodes
.
join
(
"
,
"
)}
`
);
return
moreCodes
;
}
async
getAllPureCodesFromJapaneseNames
(
names
:
string
[]):
Promise
<
number
[]
>
{
const
codes
=
await
Promise
.
all
(
names
.
map
(
s
=>
this
.
getCodeFromJapaneseName
(
s
)));
return
_
.
uniq
(
codes
);
}
async
getAllCodesFromJapaneseNames
(
names
:
string
[]):
Promise
<
number
[]
>
{
const
codes
=
_
.
flatten
(
await
Promise
.
all
(
names
.
map
(
s
=>
this
.
getCodeFromJapaneseName
(
s
))),
true
);
const
codes
=
_
.
flatten
(
await
Promise
.
all
(
names
.
map
(
s
=>
this
.
get
Extended
CodeFromJapaneseName
(
s
))),
true
);
return
_
.
uniq
(
codes
);
}
private
getDatasArray
(
datas
:
any
):
any
[]
{
...
...
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