From 883f03b1164ae5dc9afeb35f941e56590c9f3f66 Mon Sep 17 00:00:00 2001 From: Menci Date: Fri, 17 Feb 2017 10:23:27 +0800 Subject: [PATCH] Fix SQL error in statistics --- models/problem.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/models/problem.js b/models/problem.js index e78d78b..856008e 100644 --- a/models/problem.js +++ b/models/problem.js @@ -308,7 +308,10 @@ class Problem extends Model { if (!statement) return null; statement = statement.replace('__PROBLEM_ID__', this.id); - let a = (await db.query(statement + `LIMIT ${paginate.perPage} OFFSET ${(paginate.currPage - 1) * paginate.perPage}`))[0]; + + let a; + if (!paginate.pageCnt) a = []; + else a = (await db.query(statement + `LIMIT ${paginate.perPage} OFFSET ${(paginate.currPage - 1) * paginate.perPage}`))[0]; let JudgeState = syzoj.model('judge_state'); statistics.judge_state = await a.mapAsync(async x => JudgeState.fromID(x.id));