Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
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
srvpro
Commits
0e905591
Commit
0e905591
authored
Nov 15, 2020
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'database' into databasen
parents
e142379a
3aa26a21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
data-manager/DataManager.js
data-manager/DataManager.js
+11
-2
data-manager/DataManager.ts
data-manager/DataManager.ts
+12
-2
No files found.
data-manager/DataManager.js
View file @
0e905591
...
@@ -76,8 +76,17 @@ class DataManager {
...
@@ -76,8 +76,17 @@ class DataManager {
}
}
async
getRandomCloudReplay
()
{
async
getRandomCloudReplay
()
{
try
{
try
{
const
[
minQuery
,
maxQuery
]
=
await
Promise
.
all
([
"
min
"
,
"
max
"
].
map
(
minOrMax
=>
this
.
db
.
createQueryBuilder
()
.
select
(
`
${
minOrMax
}
(id)`
,
"
value
"
)
.
from
(
CloudReplay_1
.
CloudReplay
,
"
replay
"
)
.
getRawOne
()));
if
(
!
minQuery
||
maxQuery
)
{
return
null
;
}
const
targetId
=
Math
.
floor
((
maxQuery
.
value
-
minQuery
.
value
)
*
Math
.
random
())
+
minQuery
.
value
;
return
await
this
.
db
.
createQueryBuilder
(
CloudReplay_1
.
CloudReplay
,
"
replay
"
)
return
await
this
.
db
.
createQueryBuilder
(
CloudReplay_1
.
CloudReplay
,
"
replay
"
)
.
orderBy
(
"
rand()
"
)
.
where
(
"
replay.id >= :targetId
"
,
{
targetId
})
.
orderBy
(
"
replay.id
"
,
"
ASC
"
)
.
limit
(
4
)
//there may be 4 players
.
limit
(
4
)
//there may be 4 players
.
leftJoinAndSelect
(
"
replay.players
"
,
"
player
"
)
.
leftJoinAndSelect
(
"
replay.players
"
,
"
player
"
)
.
getOne
();
.
getOne
();
...
@@ -331,7 +340,7 @@ class DataManager {
...
@@ -331,7 +340,7 @@ class DataManager {
return
user
?
user
.
chatColor
:
null
;
return
user
?
user
.
chatColor
:
null
;
}
}
async
setUserChatColor
(
key
,
color
)
{
async
setUserChatColor
(
key
,
color
)
{
cons
t
user
=
await
this
.
getOrCreateUser
(
key
);
le
t
user
=
await
this
.
getOrCreateUser
(
key
);
user
.
chatColor
=
color
;
user
.
chatColor
=
color
;
return
await
this
.
saveUser
(
user
);
return
await
this
.
saveUser
(
user
);
}
}
...
...
data-manager/DataManager.ts
View file @
0e905591
...
@@ -98,8 +98,18 @@ export class DataManager {
...
@@ -98,8 +98,18 @@ export class DataManager {
async
getRandomCloudReplay
()
{
async
getRandomCloudReplay
()
{
try
{
try
{
const
[
minQuery
,
maxQuery
]
=
await
Promise
.
all
([
"
min
"
,
"
max
"
].
map
(
minOrMax
=>
this
.
db
.
createQueryBuilder
()
.
select
(
`
${
minOrMax
}
(id)`
,
"
value
"
)
.
from
(
CloudReplay
,
"
replay
"
)
.
getRawOne
()
));
if
(
!
minQuery
||
maxQuery
)
{
return
null
;
}
const
targetId
=
Math
.
floor
((
maxQuery
.
value
-
minQuery
.
value
)
*
Math
.
random
())
+
minQuery
.
value
;
return
await
this
.
db
.
createQueryBuilder
(
CloudReplay
,
"
replay
"
)
return
await
this
.
db
.
createQueryBuilder
(
CloudReplay
,
"
replay
"
)
.
orderBy
(
"
rand()
"
)
.
where
(
"
replay.id >= :targetId
"
,
{
targetId
})
.
orderBy
(
"
replay.id
"
,
"
ASC
"
)
.
limit
(
4
)
//there may be 4 players
.
limit
(
4
)
//there may be 4 players
.
leftJoinAndSelect
(
"
replay.players
"
,
"
player
"
)
.
leftJoinAndSelect
(
"
replay.players
"
,
"
player
"
)
.
getOne
();
.
getOne
();
...
@@ -355,7 +365,7 @@ export class DataManager {
...
@@ -355,7 +365,7 @@ export class DataManager {
return
user
?
user
.
chatColor
:
null
;
return
user
?
user
.
chatColor
:
null
;
}
}
async
setUserChatColor
(
key
:
string
,
color
:
string
)
{
async
setUserChatColor
(
key
:
string
,
color
:
string
)
{
cons
t
user
=
await
this
.
getOrCreateUser
(
key
);
le
t
user
=
await
this
.
getOrCreateUser
(
key
);
user
.
chatColor
=
color
;
user
.
chatColor
=
color
;
return
await
this
.
saveUser
(
user
);
return
await
this
.
saveUser
(
user
);
}
}
...
...
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