|
|
@ -200,9 +200,17 @@ app.get('/api/pass/:cid/:pid/:sid',async (req, res) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
await utop.save(); |
|
|
|
await utop.save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let newutopQuery = UToP.createQueryBuilder(); |
|
|
|
|
|
|
|
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").where("user_id=:u_id",{u_id}).andWhere("type=2").andWhere("score>100").getMany(); |
|
|
|
const scoreArray = await judgeStateQuery.select("score").addSelect("problem_id").where("user_id=:u_id",{u_id}).andWhere("type=2").andWhere("score>=100").getRawMany(); |
|
|
|
const newScore = scoreArray.reduce((acc,cur)=>{return acc.score+cur.score}) - scoreArray.length * 100; |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const 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(); |
|
|
|