Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Revive
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 Arena Revive
Commits
94859f32
Commit
94859f32
authored
Feb 21, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
/user
parent
abe143da
Pipeline
#2468
passed with stages
in 39 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
2 deletions
+70
-2
src/app.controller.ts
src/app.controller.ts
+5
-1
src/app.service.ts
src/app.service.ts
+65
-1
No files found.
src/app.controller.ts
View file @
94859f32
...
...
@@ -49,7 +49,7 @@ export class AppController {
@
Get
(
'
users
'
)
async
getUsers
(@
Query
(
'
o
'
)
orderByWhat
:
string
)
{
return
await
this
.
appService
.
getUsers
Raw
(
orderByWhat
===
'
pt
'
);
return
await
this
.
appService
.
getUsers
(
orderByWhat
===
'
pt
'
);
}
@
Get
(
'
cardinfo
'
)
...
...
@@ -225,4 +225,8 @@ export class AppController {
async
getBattleHistory
(@
Query
()
query
:
any
)
{
return
await
this
.
appService
.
getBattleHistory
(
query
);
}
@
Get
(
'
user
'
)
async
getUser
(@
Query
(
'
username
'
)
username
:
string
)
{
return
await
this
.
appService
.
getUser
(
username
);
}
}
src/app.service.ts
View file @
94859f32
...
...
@@ -184,7 +184,7 @@ export class AppService {
await
runner
.
release
();
}
async
getUsers
Raw
(
orderByPoints
:
boolean
)
{
async
getUsers
(
orderByPoints
:
boolean
)
{
const
repo
=
this
.
mcdb
.
getRepository
(
UserInfo
);
const
orderByWhat
=
orderByPoints
?
'
pt
'
:
'
exp
'
;
return
await
repo
...
...
@@ -1434,4 +1434,68 @@ export class AppService {
});
return
ret
;
}
async
getUser
(
username
:
string
)
{
const
resultData
=
{
exp
:
0
,
pt
:
1000
,
entertain_win
:
0
,
entertain_lose
:
0
,
entertain_draw
:
0
,
entertain_all
:
0
,
entertain_wl_ratio
:
'
0
'
,
exp_rank
:
0
,
athletic_win
:
0
,
athletic_lose
:
0
,
athletic_draw
:
0
,
athletic_all
:
0
,
athletic_wl_ratio
:
'
0
'
,
arena_rank
:
0
,
};
if
(
!
username
)
{
return
resultData
;
}
const
user
=
await
this
.
mcdb
.
getRepository
(
UserInfo
).
findOne
({
where
:
{
username
},
});
if
(
!
user
)
{
return
resultData
;
}
resultData
[
'
exp
'
]
=
user
[
'
exp
'
];
resultData
[
'
pt
'
]
=
user
[
'
pt
'
];
resultData
[
'
entertain_win
'
]
=
user
[
'
entertain_win
'
];
resultData
[
'
entertain_lose
'
]
=
user
[
'
entertain_lose
'
];
resultData
[
'
entertain_draw
'
]
=
user
[
'
entertain_draw
'
];
resultData
[
'
entertain_all
'
]
=
user
[
'
entertain_all
'
];
let
entertain_wl_ratio
=
'
0
'
;
if
(
user
[
'
entertain_all
'
]
>
0
)
{
entertain_wl_ratio
=
(
(
user
[
'
entertain_win
'
]
/
user
[
'
entertain_all
'
])
*
100
).
toFixed
(
2
);
}
resultData
[
'
entertain_wl_ratio
'
]
=
entertain_wl_ratio
;
resultData
[
'
athletic_win
'
]
=
user
[
'
athletic_win
'
];
resultData
[
'
athletic_lose
'
]
=
user
[
'
athletic_lose
'
];
resultData
[
'
athletic_draw
'
]
=
user
[
'
athletic_draw
'
];
resultData
[
'
athletic_all
'
]
=
user
[
'
athletic_all
'
];
let
athletic_wl_ratio
=
'
0
'
;
if
(
user
[
'
athletic_all
'
]
>
0
)
{
athletic_wl_ratio
=
(
(
user
[
'
athletic_win
'
]
/
user
[
'
athletic_all
'
])
*
100
).
toFixed
(
2
);
}
resultData
[
'
athletic_wl_ratio
'
]
=
athletic_wl_ratio
;
resultData
.
arena_rank
=
await
this
.
mcdb
.
getRepository
(
UserInfo
).
count
({
pt
:
MoreThanOrEqual
(
user
.
pt
),
});
resultData
.
exp_rank
=
await
this
.
mcdb
.
getRepository
(
UserInfo
).
count
({
exp
:
MoreThanOrEqual
(
user
.
exp
),
});
return
resultData
;
}
}
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