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