Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
JJuOn
2020-09-08 16:05:04 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fc3f94f870b8f5afa48f35deb82fddc500da8071
fc3f94f8
1 parent
76a13add
Implement /api/session/status
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletions
jaksimsamil-server/src/api/session/session.ctrl.js
jaksimsamil-server/src/api/session/session.ctrl.js
View file @
fc3f94f
...
...
@@ -6,6 +6,7 @@ const User = require("../../models/user");
const
Challenge
=
require
(
"../../models/challenge"
);
const
Problem
=
require
(
"../../models/problem"
);
const
mongoose
=
require
(
"mongoose"
);
require
(
'dotenv'
).
config
();
const
{
ObjectId
}
=
mongoose
.
Types
;
...
...
@@ -127,7 +128,25 @@ exports.status=async (ctx)=>{
}
const
participation
=
await
Participation
.
findOne
({
sessionId
:
sessionId
,
groupId
:
groupId
});
const
group
=
await
Group
.
findById
(
groupId
);
for
(
let
i
=
0
;
i
<
group
.
members
.
length
;
i
++
){
const
user
=
await
User
.
findById
(
group
.
members
[
i
]);
await
axios
.
patch
(
`http://localhost:
${
process
.
env
.
SERVER_PORT
}
/api/profile/syncBJ`
,{
username
:
user
.
username
});
}
for
(
let
i
=
0
;
i
<
group
.
members
.
length
;
i
++
){
const
user
=
await
User
.
findById
(
group
.
members
[
i
]);
let
userProblemList
=
[];
for
(
let
key
in
user
.
solvedBJ_date
.
solvedBJbyDATE
){
userProblemList
.
push
(
user
.
solvedBJ_date
.
solvedBJbyDATE
[
key
]);
}
userProblemList
=
userProblemList
.
flat
().
map
(
elem
=>
elem
.
problem_number
);
for
(
let
j
=
0
;
j
<
participation
.
problems
.
length
;
j
++
){
if
(
userProblemList
.
includes
(
String
(
participation
.
problems
[
i
].
problemNum
))){
participation
.
problems
[
i
].
isSolved
=
true
;
await
participation
.
save
();
}
}
}
ctx
.
body
=
participation
.
serialize
();
}
catch
(
e
){
ctx
.
throw
(
500
,
e
);
...
...
Please
register
or
login
to post a comment