Browse Source

Use publicize time instead

pull/6/head
hewenyang 7 years ago
parent
commit
16726a08b1
  1. 12
      models/problem.js
  2. 4
      modules/index.js
  3. 1
      modules/problem.js

12
models/problem.js

@ -244,17 +244,14 @@ let model = db.define('problem', {
file_io_input_name: { type: Sequelize.TEXT }, file_io_input_name: { type: Sequelize.TEXT },
file_io_output_name: { type: Sequelize.TEXT }, file_io_output_name: { type: Sequelize.TEXT },
create_time: { type: Sequelize.DATE }, publicize_time: { type: Sequelize.DATE },
last_update: { type: Sequelize.DATE },
type: { type: {
type: Sequelize.ENUM, type: Sequelize.ENUM,
values: ['traditional', 'submit-answer', 'interaction'] values: ['traditional', 'submit-answer', 'interaction']
} }
}, { }, {
timestamps: true, timestamps: false,
createdAt: 'create_time',
updatedAt: 'last_update',
tableName: 'problem', tableName: 'problem',
indexes: [ indexes: [
{ {
@ -264,10 +261,7 @@ let model = db.define('problem', {
fields: ['user_id'], fields: ['user_id'],
}, },
{ {
fields: ['create_time'], fields: ['publicize_time'],
},
{
fields: ['last_update'],
}, },
] ]
}); });

4
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 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, id: problem.id,
title: problem.title, title: problem.title,
time: timeAgo.format(new Date(problem.last_update)), time: timeAgo.format(new Date(problem.publicize_time)),
})); }));
res.render('index', { res.render('index', {

1
modules/problem.js

@ -581,6 +581,7 @@ async function setPublic(req, res, is_public) {
problem.is_public = is_public; problem.is_public = is_public;
problem.publicizer_id = res.locals.user.id; problem.publicizer_id = res.locals.user.id;
problem.publicize_time = new Date();
await problem.save(); await problem.save();
JudgeState.model.update( JudgeState.model.update(

Loading…
Cancel
Save