Browse Source

bugfix:优化练习成功后增加积分的逻辑。

pull/6/head
zjz1993 5 years ago
parent
commit
bf5738821b
  1. 14
      modules/practice.js

14
modules/practice.js

@ -57,12 +57,6 @@ app.get('/practice', async (req, res) => {
} }
item.isNow = item.order === currentPId; 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', { res.render('practice', {
user:res.locals.user, user:res.locals.user,
result result
@ -197,6 +191,14 @@ app.get('/api/pass/:cid/:pid',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) {
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(); res.send();
} catch(e) { } catch(e) {
res.send({ error_code: e.errno, error_msg: '练习失败,请稍后重试' }); res.send({ error_code: e.errno, error_msg: '练习失败,请稍后重试' });

Loading…
Cancel
Save