|
|
@ -201,6 +201,7 @@ let Sequelize = require('sequelize'); |
|
|
|
let db = syzoj.db; |
|
|
|
let db = syzoj.db; |
|
|
|
|
|
|
|
|
|
|
|
let User = syzoj.model('user'); |
|
|
|
let User = syzoj.model('user'); |
|
|
|
|
|
|
|
let JudgeState = syzoj.model('judge_state'); |
|
|
|
let File = syzoj.model('file'); |
|
|
|
let File = syzoj.model('file'); |
|
|
|
const fs = require('fs-extra'); |
|
|
|
const fs = require('fs-extra'); |
|
|
|
const path = require('path'); |
|
|
|
const path = require('path'); |
|
|
@ -472,8 +473,6 @@ class Problem extends Model { |
|
|
|
async getJudgeState(user, acFirst) { |
|
|
|
async getJudgeState(user, acFirst) { |
|
|
|
if (!user) return null; |
|
|
|
if (!user) return null; |
|
|
|
|
|
|
|
|
|
|
|
let JudgeState = syzoj.model('judge_state'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let where = { |
|
|
|
let where = { |
|
|
|
user_id: user.id, |
|
|
|
user_id: user.id, |
|
|
|
problem_id: this.id |
|
|
|
problem_id: this.id |
|
|
@ -498,6 +497,12 @@ class Problem extends Model { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async resetSubmissionCount() { |
|
|
|
|
|
|
|
this.submit_num = await JudgeState.count({ score: { $not: null }, problem_id: this.id }); |
|
|
|
|
|
|
|
this.ac_num = await JudgeState.count({ score: 100, problem_id: this.id }); |
|
|
|
|
|
|
|
await this.save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// type: fastest / slowest / shortest / longest / earliest
|
|
|
|
// type: fastest / slowest / shortest / longest / earliest
|
|
|
|
async countStatistics(type) { |
|
|
|
async countStatistics(type) { |
|
|
|
let statement = statisticsStatements[type]; |
|
|
|
let statement = statisticsStatements[type]; |
|
|
@ -585,10 +590,12 @@ class Problem extends Model { |
|
|
|
let addTagIDs = newTagIDs.filter(x => !oldTagIDs.includes(x)); |
|
|
|
let addTagIDs = newTagIDs.filter(x => !oldTagIDs.includes(x)); |
|
|
|
|
|
|
|
|
|
|
|
for (let tagID of delTagIDs) { |
|
|
|
for (let tagID of delTagIDs) { |
|
|
|
let map = await ProblemTagMap.findOne({ where: { |
|
|
|
let map = await ProblemTagMap.findOne({ |
|
|
|
|
|
|
|
where: { |
|
|
|
problem_id: this.id, |
|
|
|
problem_id: this.id, |
|
|
|
tag_id: tagID |
|
|
|
tag_id: tagID |
|
|
|
} }); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await map.destroy(); |
|
|
|
await map.destroy(); |
|
|
|
} |
|
|
|
} |
|
|
|