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
1c949e19
Commit
1c949e19
authored
Feb 19, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transaction
parent
f6e10b09
Pipeline
#2455
passed with stages
in 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
86 deletions
+108
-86
src/app.service.ts
src/app.service.ts
+108
-86
No files found.
src/app.service.ts
View file @
1c949e19
...
@@ -718,35 +718,44 @@ export class AppService {
...
@@ -718,35 +718,44 @@ export class AppService {
battleHistory
.
isfirstwin
=
firstWin
;
battleHistory
.
isfirstwin
=
firstWin
;
battleHistory
.
decka
=
deckA
;
battleHistory
.
decka
=
deckA
;
battleHistory
.
deckb
=
deckB
;
battleHistory
.
deckb
=
deckB
;
await
Promise
.
all
([
await
this
.
transaction
(
this
.
mcdb
,
async
(
db
)
=>
{
repo
.
save
(
battleHistory
),
const
repo
=
db
.
getRepository
(
BattleHistory
);
this
.
mcdb
try
{
.
createQueryBuilder
()
await
Promise
.
all
([
.
update
(
UserInfo
)
repo
.
save
(
battleHistory
),
.
set
({
db
exp
:
expResult
.
expA
,
.
createQueryBuilder
()
pt
:
ptResult
.
ptA
,
.
update
(
UserInfo
)
athleticWin
:
()
=>
`athletic_win +
${
paramA
.
athletic_win
}
`
,
.
set
({
athleticLose
:
()
=>
`athletic_lose +
${
paramA
.
athletic_win
}
`
,
exp
:
expResult
.
expA
,
athleticDraw
:
()
=>
`athletic_draw +
${
paramA
.
athletic_win
}
`
,
pt
:
ptResult
.
ptA
,
athleticAll
:
()
=>
`athletic_all +
${
paramA
.
athletic_win
}
`
,
athleticWin
:
()
=>
`athletic_win +
${
paramA
.
athletic_win
}
`
,
})
athleticLose
:
()
=>
`athletic_lose +
${
paramA
.
athletic_win
}
`
,
.
where
(
'
username = :username
'
,
{
username
:
userA
.
username
})
athleticDraw
:
()
=>
`athletic_draw +
${
paramA
.
athletic_win
}
`
,
.
execute
(),
athleticAll
:
()
=>
`athletic_all +
${
paramA
.
athletic_win
}
`
,
this
.
mcdb
})
.
createQueryBuilder
()
.
where
(
'
username = :username
'
,
{
username
:
userA
.
username
})
.
update
(
UserInfo
)
.
execute
(),
.
set
({
db
exp
:
expResult
.
expB
,
.
createQueryBuilder
()
pt
:
ptResult
.
ptB
,
.
update
(
UserInfo
)
athleticWin
:
()
=>
`athletic_win +
${
paramB
.
athletic_win
}
`
,
.
set
({
athleticLose
:
()
=>
`athletic_lose +
${
paramB
.
athletic_win
}
`
,
exp
:
expResult
.
expB
,
athleticDraw
:
()
=>
`athletic_draw +
${
paramB
.
athletic_win
}
`
,
pt
:
ptResult
.
ptB
,
athleticAll
:
()
=>
`athletic_all +
${
paramB
.
athletic_win
}
`
,
athleticWin
:
()
=>
`athletic_win +
${
paramB
.
athletic_win
}
`
,
})
athleticLose
:
()
=>
`athletic_lose +
${
paramB
.
athletic_win
}
`
,
.
where
(
'
username = :username
'
,
{
username
:
userB
.
username
})
athleticDraw
:
()
=>
`athletic_draw +
${
paramB
.
athletic_win
}
`
,
.
execute
(),
athleticAll
:
()
=>
`athletic_all +
${
paramB
.
athletic_win
}
`
,
]);
})
.
where
(
'
username = :username
'
,
{
username
:
userB
.
username
})
.
execute
(),
]);
return
true
;
}
catch
(
e
)
{
this
.
log
.
error
(
`Failed to report score:
${
e
.
toString
()}
`
);
return
false
;
}
});
}
else
{
}
else
{
const
expResult
=
EloUtility
.
getExpScore
(
const
expResult
=
EloUtility
.
getExpScore
(
userA
.
exp
,
userA
.
exp
,
...
@@ -788,33 +797,42 @@ export class AppService {
...
@@ -788,33 +797,42 @@ export class AppService {
battleHistory
.
isfirstwin
=
firstWin
;
battleHistory
.
isfirstwin
=
firstWin
;
battleHistory
.
decka
=
deckA
;
battleHistory
.
decka
=
deckA
;
battleHistory
.
deckb
=
deckB
;
battleHistory
.
deckb
=
deckB
;
await
Promise
.
all
([
await
this
.
transaction
(
this
.
mcdb
,
async
(
db
)
=>
{
repo
.
save
(
battleHistory
),
const
repo
=
db
.
getRepository
(
BattleHistory
);
this
.
mcdb
try
{
.
createQueryBuilder
()
await
Promise
.
all
([
.
update
(
UserInfo
)
repo
.
save
(
battleHistory
),
.
set
({
db
exp
:
expResult
.
expA
,
.
createQueryBuilder
()
athleticWin
:
()
=>
`athletic_win +
${
paramA
.
athletic_win
}
`
,
.
update
(
UserInfo
)
athleticLose
:
()
=>
`athletic_lose +
${
paramA
.
athletic_win
}
`
,
.
set
({
athleticDraw
:
()
=>
`athletic_draw +
${
paramA
.
athletic_win
}
`
,
exp
:
expResult
.
expA
,
athleticAll
:
()
=>
`athletic_all +
${
paramA
.
athletic_win
}
`
,
entertainWin
:
()
=>
`entertain_win +
${
paramA
.
entertain_win
}
`
,
})
entertainLose
:
()
=>
`entertain_lose +
${
paramA
.
entertain_win
}
`
,
.
where
(
'
username = :username
'
,
{
username
:
userA
.
username
})
entertainDraw
:
()
=>
`entertain_draw +
${
paramA
.
entertain_win
}
`
,
.
execute
(),
entertainAll
:
()
=>
`entertain_all +
${
paramA
.
entertain_win
}
`
,
this
.
mcdb
})
.
createQueryBuilder
()
.
where
(
'
username = :username
'
,
{
username
:
userA
.
username
})
.
update
(
UserInfo
)
.
execute
(),
.
set
({
db
exp
:
expResult
.
expB
,
.
createQueryBuilder
()
athleticWin
:
()
=>
`athletic_win +
${
paramB
.
athletic_win
}
`
,
.
update
(
UserInfo
)
athleticLose
:
()
=>
`athletic_lose +
${
paramB
.
athletic_win
}
`
,
.
set
({
athleticDraw
:
()
=>
`athletic_draw +
${
paramB
.
athletic_win
}
`
,
exp
:
expResult
.
expB
,
athleticAll
:
()
=>
`athletic_all +
${
paramB
.
athletic_win
}
`
,
entertainWin
:
()
=>
`entertain_win +
${
paramB
.
entertain_win
}
`
,
})
entertainLose
:
()
=>
`entertain_lose +
${
paramB
.
entertain_win
}
`
,
.
where
(
'
username = :username
'
,
{
username
:
userB
.
username
})
entertainDraw
:
()
=>
`entertain_draw +
${
paramB
.
entertain_win
}
`
,
.
execute
(),
entertainAll
:
()
=>
`entertain_all +
${
paramB
.
entertain_win
}
`
,
]);
})
.
where
(
'
username = :username
'
,
{
username
:
userB
.
username
})
.
execute
(),
]);
return
true
;
}
catch
(
e
)
{
this
.
log
.
error
(
`Failed to report score:
${
e
.
toString
()}
`
);
return
false
;
}
});
}
}
return
null
;
return
null
;
...
@@ -893,43 +911,47 @@ export class AppService {
...
@@ -893,43 +911,47 @@ export class AppService {
const
date_time
=
moment
().
format
(
'
YYYY-MM-DD
'
);
const
date_time
=
moment
().
format
(
'
YYYY-MM-DD
'
);
const
create_time
=
moment
().
toDate
();
const
create_time
=
moment
().
toDate
();
const
repo
=
this
.
mcdb
.
getRepository
(
VoteResult
);
let
statusCode
=
200
;
try
{
await
this
.
transaction
(
this
.
mcdb
,
async
(
db
)
=>
{
if
(
multiple
)
{
const
repo
=
db
.
getRepository
(
VoteResult
);
if
(
!
opids
)
{
try
{
return
400
;
if
(
multiple
)
{
}
if
(
!
opids
)
{
const
voteResults
=
opids
.
map
((
opid
)
=>
{
statusCode
=
400
;
return
false
;
}
const
voteResults
=
opids
.
map
((
opid
)
=>
{
const
voteResult
=
new
VoteResult
();
voteResult
.
voteId
=
voteid
;
voteResult
.
optionId
=
opid
;
voteResult
.
userid
=
user
;
voteResult
.
dateTime
=
date_time
;
voteResult
.
createTime
=
create_time
;
return
voteResult
;
});
await
repo
.
save
(
voteResults
);
}
else
{
const
voteResult
=
new
VoteResult
();
const
voteResult
=
new
VoteResult
();
voteResult
.
voteId
=
voteid
;
voteResult
.
voteId
=
voteid
;
voteResult
.
optionId
=
opid
;
voteResult
.
optionId
=
opid
;
voteResult
.
userid
=
user
;
voteResult
.
userid
=
user
;
voteResult
.
dateTime
=
date_time
;
voteResult
.
dateTime
=
date_time
;
voteResult
.
createTime
=
create_time
;
voteResult
.
createTime
=
create_time
;
return
voteResult
;
await
repo
.
save
(
voteResult
);
});
}
await
Promise
.
all
(
if
(
username
)
{
voteResults
.
map
((
voteResult
)
=>
repo
.
save
(
voteResult
)),
await
db
);
.
getRepository
(
UserInfo
)
}
else
{
.
update
({
username
},
{
exp
:
()
=>
'
exp + 1
'
,
id
:
parseInt
(
user
)
});
const
voteResult
=
new
VoteResult
();
}
voteResult
.
voteId
=
voteid
;
return
true
;
voteResult
.
optionId
=
opid
;
}
catch
(
e
)
{
voteResult
.
userid
=
user
;
this
.
log
.
error
(
`Failed updating vote result:
${
e
.
toString
()}
`
);
voteResult
.
dateTime
=
date_time
;
statusCode
=
500
;
voteResult
.
createTime
=
create_time
;
return
false
;
await
repo
.
save
(
voteResult
);
}
if
(
username
)
{
await
this
.
mcdb
.
getRepository
(
UserInfo
)
.
update
({
username
},
{
exp
:
()
=>
'
exp + 1
'
,
id
:
parseInt
(
user
)
});
}
}
return
200
;
});
}
catch
(
e
)
{
return
statusCode
;
this
.
log
.
error
(
`Failed updating vote result:
${
e
.
toString
()}
`
);
return
500
;
}
}
}
private
async
fetchVoteOptionCount
(
private
async
fetchVoteOptionCount
(
...
...
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