|
|
|
@ -204,19 +204,23 @@ app.get('/api/pass/:cid/:pid/:sid',async (req, res) => {
|
|
|
|
|
let userACArray = await newutopQuery.select("p_id").where('u_id=:u_id',{u_id}).andWhere("is_finished=1").getRawMany(); |
|
|
|
|
if (syzoj.config.practice_rating) { |
|
|
|
|
const scoreArray = await judgeStateQuery.select("score").addSelect("problem_id").where("user_id=:u_id",{u_id}).andWhere("type=2").andWhere("score>=100").getRawMany(); |
|
|
|
|
let num = 0; |
|
|
|
|
for(let i=0;i<userACArray.length;i++){ |
|
|
|
|
const problem_id = userACArray[i].p_id; |
|
|
|
|
const item = scoreArray.find(item => item.problem_id === problem_id) |
|
|
|
|
num+=parseInt(item.score); |
|
|
|
|
let newScore = 0; |
|
|
|
|
if (scoreArray && scoreArray.length !== 0) { |
|
|
|
|
let num = 0; |
|
|
|
|
for(let i=0;i<userACArray.length;i++){ |
|
|
|
|
const problem_id = userACArray[i].p_id; |
|
|
|
|
const item = scoreArray.find(item => item.problem_id === problem_id) |
|
|
|
|
num+=parseInt(item.score); |
|
|
|
|
} |
|
|
|
|
newScore = num - userACArray.length * 100; |
|
|
|
|
} |
|
|
|
|
const newScore = num - userACArray.length * 100; |
|
|
|
|
const originRating = syzoj.config.default.user.rating; |
|
|
|
|
const newRating = originRating + newScore; |
|
|
|
|
await userQuery.update(User).set({rating: newRating}).where('id=:u_id',{u_id}).execute(); |
|
|
|
|
res.send({newRating: newRating}); |
|
|
|
|
} |
|
|
|
|
} catch(e) { |
|
|
|
|
console.log(e); |
|
|
|
|
res.send({ error_code: e.errno, error_msg: '练习失败,请稍后重试' }); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|