Showing
1 changed file
with
20 additions
and
1 deletions
... | @@ -6,6 +6,7 @@ const User = require("../../models/user"); | ... | @@ -6,6 +6,7 @@ const User = require("../../models/user"); |
6 | const Challenge = require("../../models/challenge"); | 6 | const Challenge = require("../../models/challenge"); |
7 | const Problem = require("../../models/problem"); | 7 | const Problem = require("../../models/problem"); |
8 | const mongoose = require("mongoose"); | 8 | const mongoose = require("mongoose"); |
9 | +require('dotenv').config(); | ||
9 | 10 | ||
10 | const {ObjectId} = mongoose.Types; | 11 | const {ObjectId} = mongoose.Types; |
11 | 12 | ||
... | @@ -127,7 +128,25 @@ exports.status=async (ctx)=>{ | ... | @@ -127,7 +128,25 @@ exports.status=async (ctx)=>{ |
127 | } | 128 | } |
128 | const participation=await Participation.findOne({sessionId:sessionId,groupId:groupId}); | 129 | const participation=await Participation.findOne({sessionId:sessionId,groupId:groupId}); |
129 | const group = await Group.findById(groupId); | 130 | const group = await Group.findById(groupId); |
130 | - | 131 | + for(let i=0;i<group.members.length;i++){ |
132 | + const user=await User.findById(group.members[i]); | ||
133 | + await axios.patch(`http://localhost:${process.env.SERVER_PORT}/api/profile/syncBJ`,{username:user.username}); | ||
134 | + } | ||
135 | + for(let i=0;i<group.members.length;i++){ | ||
136 | + const user=await User.findById(group.members[i]); | ||
137 | + let userProblemList = []; | ||
138 | + for(let key in user.solvedBJ_date.solvedBJbyDATE){ | ||
139 | + userProblemList.push(user.solvedBJ_date.solvedBJbyDATE[key]); | ||
140 | + } | ||
141 | + userProblemList=userProblemList.flat().map(elem=>elem.problem_number); | ||
142 | + for(let j=0;j<participation.problems.length;j++){ | ||
143 | + if(userProblemList.includes(String(participation.problems[i].problemNum))){ | ||
144 | + participation.problems[i].isSolved=true; | ||
145 | + await participation.save(); | ||
146 | + } | ||
147 | + } | ||
148 | + } | ||
149 | + ctx.body=participation.serialize(); | ||
131 | } | 150 | } |
132 | catch(e){ | 151 | catch(e){ |
133 | ctx.throw(500,e); | 152 | ctx.throw(500,e); | ... | ... |
-
Please register or login to post a comment