|
|
@ -21,7 +21,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
let statisticsStatements = { |
|
|
|
let statisticsStatements = { |
|
|
|
fastest: |
|
|
|
fastest: |
|
|
|
'\ |
|
|
|
'\ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -46,7 +46,7 @@ WHERE \ |
|
|
|
ORDER BY `total_time` ASC \ |
|
|
|
ORDER BY `total_time` ASC \ |
|
|
|
', |
|
|
|
', |
|
|
|
slowest: |
|
|
|
slowest: |
|
|
|
' \ |
|
|
|
' \ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -71,7 +71,7 @@ WHERE \ |
|
|
|
ORDER BY `total_time` DESC \ |
|
|
|
ORDER BY `total_time` DESC \ |
|
|
|
', |
|
|
|
', |
|
|
|
shortest: |
|
|
|
shortest: |
|
|
|
' \ |
|
|
|
' \ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -96,7 +96,7 @@ WHERE \ |
|
|
|
ORDER BY `code_length` ASC \ |
|
|
|
ORDER BY `code_length` ASC \ |
|
|
|
', |
|
|
|
', |
|
|
|
longest: |
|
|
|
longest: |
|
|
|
' \ |
|
|
|
' \ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -121,7 +121,7 @@ WHERE \ |
|
|
|
ORDER BY `code_length` DESC \ |
|
|
|
ORDER BY `code_length` DESC \ |
|
|
|
', |
|
|
|
', |
|
|
|
earliest: |
|
|
|
earliest: |
|
|
|
' \ |
|
|
|
' \ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -146,7 +146,7 @@ WHERE \ |
|
|
|
ORDER BY `submit_time` ASC \ |
|
|
|
ORDER BY `submit_time` ASC \ |
|
|
|
', |
|
|
|
', |
|
|
|
min: |
|
|
|
min: |
|
|
|
' \ |
|
|
|
' \ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -171,7 +171,7 @@ WHERE \ |
|
|
|
ORDER BY `max_memory` ASC \ |
|
|
|
ORDER BY `max_memory` ASC \ |
|
|
|
', |
|
|
|
', |
|
|
|
max: |
|
|
|
max: |
|
|
|
' \ |
|
|
|
' \ |
|
|
|
SELECT \ |
|
|
|
SELECT \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
DISTINCT(`user_id`) AS `user_id`, \ |
|
|
|
( \ |
|
|
|
( \ |
|
|
@ -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'); |
|
|
@ -259,7 +260,7 @@ let model = db.define('problem', { |
|
|
|
fields: ['user_id'], |
|
|
|
fields: ['user_id'], |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let Model = require('./common'); |
|
|
|
let Model = require('./common'); |
|
|
|
class Problem extends Model { |
|
|
|
class Problem extends Model { |
|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|