From 82f5e26836eb95fd4694c0c4bf3eee5b16aaa855 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Fri, 19 Jul 2019 16:57:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=BB=83=E4=B9=A0?= =?UTF-8?q?=E9=A2=98=E6=88=90=E5=8A=9F=E6=97=B6=E5=8A=A0=E5=88=86=E7=9A=84?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=88=A4=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/practice.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/practice.js b/modules/practice.js index 43a6250..a07b8a7 100644 --- a/modules/practice.js +++ b/modules/practice.js @@ -23,7 +23,7 @@ app.get('/practice', async (req, res) => { let userQuery = await User.createQueryBuilder(); const userId = res.locals.user.id; let currentPId = await getUserInfo(userId); - const test = []; + const unFinishedIdArray = []; if (!currentPId) { // 用户第一次进入练习板块 await userQuery.update(User).set({current_p_id: 1}).where("id = :id", { id:userId }).execute(); @@ -42,8 +42,8 @@ app.get('/practice', async (req, res) => { } }); } - if (test.length !== 0) { - const minOrder = Math.min.apply(null,test); + if (unFinishedIdArray.length !== 0) { + const minOrder = Math.min.apply(null,unFinishedIdArray); currentPId = minOrder; await userQuery.update(User).set({current_p_id: minOrder}).where("id = :id", { id:userId }).execute(); } @@ -57,10 +57,11 @@ 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(); - - 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(); + 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,