modlog bugfix

merge-requests/208/head
fatchan 5 years ago
parent 8484d12e38
commit 90fa066261
  1. 4
      db/modlogs.js
  2. 2
      helpers/build.js
  3. 4
      helpers/datearray.js
  4. 4
      models/forms/create.js
  5. 5
      models/pages/modlog.js

@ -8,13 +8,13 @@ module.exports = {
getFirst: (board) => { getFirst: (board) => {
return db.find({ return db.find({
'board': board._id 'board': board._id
}).sort({_id:-1}).limit(1).toArray(); }).sort({_id:1}).limit(1).toArray();
}, },
getLast: (board) => { getLast: (board) => {
return db.find({ return db.find({
'board': board._id 'board': board._id
}).sort({_id:1}).limit(1).toArray(); }).sort({_id:-1}).limit(1).toArray();
}, },
findBetweenDate: (board, start, end) => { findBetweenDate: (board, start, end) => {

@ -145,7 +145,7 @@ module.exports = {
const firstLogDate = firstLog[0].date; const firstLogDate = firstLog[0].date;
firstLogDate.setHours(1,0,0,0); firstLogDate.setHours(1,0,0,0);
const lastLogDate = lastLog[0].date; const lastLogDate = lastLog[0].date;
dates = dateArray(firstLogDate, lastLogDate); dates = dateArray(firstLogDate, lastLogDate).reverse();
} }
await render(label, 'modloglist.pug', { await render(label, 'modloglist.pug', {
board, board,

@ -2,8 +2,8 @@
//https://stackoverflow.com/a/4413721 //https://stackoverflow.com/a/4413721
module.exports = (startDate, stopDate) => { module.exports = (startDate, stopDate) => {
var dateArray = new Array(); const dateArray = new Array();
var currentDate = startDate; let currentDate = startDate;
while (currentDate <= stopDate) { while (currentDate <= stopDate) {
dateArray.push(new Date (currentDate.valueOf())); dateArray.push(new Date (currentDate.valueOf()));
currentDate.setDate(currentDate.getDate() + 1); currentDate.setDate(currentDate.getDate() + 1);

@ -32,8 +32,8 @@ module.exports = async (req, res, next) => {
'moderators': [], 'moderators': [],
'locked': false, 'locked': false,
'captchaMode': 0, 'captchaMode': 0,
'tphTrigger': 0, 'tphTrigger': 10,
'tphTriggerAction': 0, 'tphTriggerAction': 1,
'forceAnon': false, 'forceAnon': false,
'early404': true, 'early404': true,
'ids': false, 'ids': false,

@ -10,11 +10,10 @@ module.exports = async (req, res, next) => {
return next(); return next();
} }
const startDate = res.locals.date; const startDate = new Date(res.locals.date);
const endDate = new Date(startDate.getTime()); const endDate = new Date(startDate.valueOf());
startDate.setHours(0,0,0,0); startDate.setHours(0,0,0,0);
endDate.setHours(23,59,59,999); endDate.setHours(23,59,59,999);
try { try {
const logs = await Modlogs.findBetweenDate(res.locals.board, startDate, endDate); const logs = await Modlogs.findBetweenDate(res.locals.board, startDate, endDate);
if (!logs || logs.length === 0) { if (!logs || logs.length === 0) {

Loading…
Cancel
Save