mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-20 00:50:24 +02:00
fix(forums): fixed forums new topic and replies count issue
This commit is contained in:
4
config/env/torrents.js
vendored
4
config/env/torrents.js
vendored
@@ -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
|
||||
},
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user