diff --git a/modules/practice.js b/modules/practice.js index 3e0e36e..c21d7d6 100644 --- a/modules/practice.js +++ b/modules/practice.js @@ -57,12 +57,6 @@ app.get('/practice', async (req, res) => { } item.isNow = item.order === currentPId; }); - let userACArray = await utopQuery.where('u_id=:u_id',{u_id:userId}).andWhere("is_finished=1").getMany(); - if (syzoj.config.practice_rating) { - const originRating = syzoj.config.default.user.rating; - const newRating = originRating + userACArray.length * syzoj.config.practice_rating; - await userQuery.update(User).set({rating: newRating}).where('id=:u_id',{u_id:userId}).execute(); - } res.render('practice', { user:res.locals.user, result @@ -197,6 +191,14 @@ app.get('/api/pass/:cid/:pid',async (req, res) => { }); 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) { + const originRating = syzoj.config.default.user.rating; + const newRating = originRating + userACArray.length * syzoj.config.practice_rating; + await userQuery.update(User).set({rating: newRating}).where('id=:u_id',{u_id}).execute(); + } res.send(); } catch(e) { res.send({ error_code: e.errno, error_msg: '练习失败,请稍后重试' });