|
|
@ -1,4 +1,5 @@ |
|
|
|
let Classify = syzoj.model('classify'); |
|
|
|
let Classify = syzoj.model('classify'); |
|
|
|
|
|
|
|
let JudgeState = syzoj.model('judge_state'); |
|
|
|
let Problem = syzoj.model('problem'); |
|
|
|
let Problem = syzoj.model('problem'); |
|
|
|
let CToP = syzoj.model('classify_to_problem'); |
|
|
|
let CToP = syzoj.model('classify_to_problem'); |
|
|
|
let Article = syzoj.model('article'); |
|
|
|
let Article = syzoj.model('article'); |
|
|
@ -176,6 +177,7 @@ app.get('/api/pass/:cid/:pid/:sid',async (req, res) => { |
|
|
|
let utopQuery = UToP.createQueryBuilder(); |
|
|
|
let utopQuery = UToP.createQueryBuilder(); |
|
|
|
let query = Classify.createQueryBuilder(); |
|
|
|
let query = Classify.createQueryBuilder(); |
|
|
|
let userQuery = User.createQueryBuilder(); |
|
|
|
let userQuery = User.createQueryBuilder(); |
|
|
|
|
|
|
|
let judgeStateQuery = JudgeState.createQueryBuilder(); |
|
|
|
let classify = await Classify.queryAll(query); |
|
|
|
let classify = await Classify.queryAll(query); |
|
|
|
classify.sort(function(a,b) { |
|
|
|
classify.sort(function(a,b) { |
|
|
|
return a.order - b.order; |
|
|
|
return a.order - b.order; |
|
|
@ -198,12 +200,11 @@ app.get('/api/pass/:cid/:pid/:sid',async (req, res) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
await utop.save(); |
|
|
|
await utop.save(); |
|
|
|
} |
|
|
|
} |
|
|
|
let newutopQuery = UToP.createQueryBuilder(); |
|
|
|
|
|
|
|
let userACArray = await newutopQuery.where('u_id=:u_id',{u_id}).andWhere("is_finished=1").getMany(); |
|
|
|
|
|
|
|
console.log(userACArray.length); |
|
|
|
|
|
|
|
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 newScore = scoreArray.reduce((acc,cur)=>{return acc.score+cur.score}) - scoreArray.length * 100; |
|
|
|
const originRating = syzoj.config.default.user.rating; |
|
|
|
const originRating = syzoj.config.default.user.rating; |
|
|
|
const newRating = originRating + userACArray.length * syzoj.config.practice_rating; |
|
|
|
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(); |
|
|
|
res.send(); |
|
|
|