From 16726a08b1c41ff708205a21a9c841f4f791f271 Mon Sep 17 00:00:00 2001 From: hewenyang Date: Sat, 14 Apr 2018 17:04:50 +0000 Subject: [PATCH] Use publicize time instead --- models/problem.js | 12 +++--------- modules/index.js | 4 ++-- modules/problem.js | 1 + 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/models/problem.js b/models/problem.js index e89eccb..9014e25 100644 --- a/models/problem.js +++ b/models/problem.js @@ -244,17 +244,14 @@ let model = db.define('problem', { file_io_input_name: { type: Sequelize.TEXT }, file_io_output_name: { type: Sequelize.TEXT }, - create_time: { type: Sequelize.DATE }, - last_update: { type: Sequelize.DATE }, + publicize_time: { type: Sequelize.DATE }, type: { type: Sequelize.ENUM, values: ['traditional', 'submit-answer', 'interaction'] } }, { - timestamps: true, - createdAt: 'create_time', - updatedAt: 'last_update', + timestamps: false, tableName: 'problem', indexes: [ { @@ -264,10 +261,7 @@ let model = db.define('problem', { fields: ['user_id'], }, { - fields: ['create_time'], - }, - { - fields: ['last_update'], + fields: ['publicize_time'], }, ] }); diff --git a/modules/index.js b/modules/index.js index 023686e..73741a4 100644 --- a/modules/index.js +++ b/modules/index.js @@ -47,10 +47,10 @@ app.get('/', async (req, res) => { let contests = await Contest.query([1, 5], { is_public: true }, [['start_time', 'desc']]); - let problems = (await Problem.query([1, 5], { is_public: true }, [['last_update', 'desc']])).map(problem => ({ + let problems = (await Problem.query([1, 5], { is_public: true }, [['publicize_time', 'desc']])).map(problem => ({ id: problem.id, title: problem.title, - time: timeAgo.format(new Date(problem.last_update)), + time: timeAgo.format(new Date(problem.publicize_time)), })); res.render('index', { diff --git a/modules/problem.js b/modules/problem.js index f30da2d..dcc990d 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -581,6 +581,7 @@ async function setPublic(req, res, is_public) { problem.is_public = is_public; problem.publicizer_id = res.locals.user.id; + problem.publicize_time = new Date(); await problem.save(); JudgeState.model.update(