diff --git a/config/env/torrents.js b/config/env/torrents.js index b1899421..0c033a9e 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -20,7 +20,7 @@ module.exports = { * @admin: site admin mail address * @showDemoWarningPopup: if is demo site, show warning popup whene home is opened for the first time. * @cronTimeZone: timezone of cron - * @dbTimeZone: timezone of mongo db + * @dbTimeZone: timezone of mongo db, in minute * @showClientDebugLog: if true, will console.log all debug info at client side. when your site is prod env, please change this * value to false, then console.log info is not output * @writeServerDebugLog: if true, will console.log all debug info at server side. when your site is prod env, please change this @@ -32,7 +32,7 @@ module.exports = { admin: 'admin@mean.im', showDemoWarningPopup: true, cronTimeZone: 'Asia/Shanghai', - dbTimeZone: '+08:00', + dbTimeZone: 480, showClientDebugLog: true, writeServerDebugLog: true }, diff --git a/modules/forums/server/controllers/forums.server.controller.js b/modules/forums/server/controllers/forums.server.controller.js index 834f574f..fe331f45 100644 --- a/modules/forums/server/controllers/forums.server.controller.js +++ b/modules/forums/server/controllers/forums.server.controller.js @@ -24,6 +24,7 @@ var scoreConfig = config.meanTorrentConfig.score; var serverMessage = require(path.resolve('./config/lib/server-message')); var serverNoticeConfig = config.meanTorrentConfig.serverNotice; var itemsPerPageConfig = config.meanTorrentConfig.itemsPerPage; +var appConfig = config.meanTorrentConfig.app; var mtDebug = require(path.resolve('./config/lib/debug')); @@ -63,25 +64,26 @@ exports.list = function (req, res) { }; var forumsTopicsCount = function (callback) { + Topic.aggregate({ // $match: condition, $project: { 'forum': '$forum', 'year': { - '$year': '$createdAt' + '$year': {'$add': ['$createdAt', appConfig.dbTimeZone * 60 * 1000]} }, 'month': { - '$month': '$createdAt' + '$month': {'$add': ['$createdAt', appConfig.dbTimeZone * 60 * 1000]} }, 'day': { - '$dayOfMonth': '$createdAt' + '$dayOfMonth': {'$add': ['$createdAt', appConfig.dbTimeZone * 60 * 1000]} } } }, { $match: { - year: moment.utc().year(), - month: moment.utc().month() + 1, - day: moment.utc().date() + year: moment().utcOffset(appConfig.dbTimeZone).year(), + month: moment().utcOffset(appConfig.dbTimeZone).month() + 1, + day: moment().utcOffset(appConfig.dbTimeZone).date() } }, { $group: { @@ -104,20 +106,20 @@ exports.list = function (req, res) { $project: { 'forum': '$forum', 'year': { - '$year': '$_replies.createdAt' + '$year': {'$add': ['$_replies.createdAt', appConfig.dbTimeZone * 60 * 1000]} }, 'month': { - '$month': '$_replies.createdAt' + '$month': {'$add': ['$_replies.createdAt', appConfig.dbTimeZone * 60 * 1000]} }, 'day': { - '$dayOfMonth': '$_replies.createdAt' + '$dayOfMonth': {'$add': ['$_replies.createdAt', appConfig.dbTimeZone * 60 * 1000]} } } }, { $match: { - year: moment.utc().year(), - month: moment.utc().month() + 1, - day: moment.utc().date() + year: moment().utcOffset(appConfig.dbTimeZone).year(), + month: moment().utcOffset(appConfig.dbTimeZone).month() + 1, + day: moment().utcOffset(appConfig.dbTimeZone).date() } }, { $group: {