feat(home): add idle and banned users count on home

This commit is contained in:
OldHawk
2018-04-28 12:34:07 +08:00
parent 9778ab2823
commit f5a7f941dd
4 changed files with 43 additions and 2 deletions

View File

@@ -1107,6 +1107,8 @@
SITE_STATEMENT: '<h3>Disclaimer</h3> This site serves as a platform for users to share and discuss Internet resources. The site itself does not provide any resources for download, nor does it store any resource files on the server. The users behavior is not related to this site. If you feel that some users share has infringed your legal rights, please immediately contact to our <strong>{{sNameDesc | translate}}</strong> by <strong><a href="Mailto:{{sMail}}">mail</a></strong>, we will verify and process it as soon as possible.',
TOTAL_USERS: 'Total Users',
TOTAL_VIP_USERS: 'Total VIP Users',
TOTAL_IDLE_USERS: 'Total Idle Users',
TOTAL_BANNED_USERS: 'Total Banned Users',
TOTAL_TORRENTS: 'Total Torrents',
TOTAL_TORRENTSSIZE: 'Total TorrentsSize',
TOTAL_SEEDERS: 'Total Seeders',

View File

@@ -1107,6 +1107,8 @@
SITE_STATEMENT: '<h3>免责声明</h3>本站仅作为用户对互联网资源的分享讨论交流平台,站内本身不提供任何资源下载,也不在服务器存储任何资源文件,用户自行分享的行为与本站无关,如果您觉得某些用户的分享侵犯了您的合法权益,请立即向我们的 <strong>{{sNameDesc | translate}}</strong> 发送 <strong><a href="mailto:{{sMail}}">邮件</a></strong>,我们将会尽快核实并处理。',
TOTAL_USERS: '注册会员',
TOTAL_VIP_USERS: 'VIP会员',
TOTAL_IDLE_USERS: '空闲用户',
TOTAL_BANNED_USERS: '禁止用户',
TOTAL_TORRENTS: '种子数',
TOTAL_TORRENTSSIZE: '种子总体积',
TOTAL_SEEDERS: '正在做种',

View File

@@ -8,6 +8,10 @@
class="item-data">{{vm.siteInfo.totalUsers}}</span></div>
<div class="info-item col-xs-6 col-xs-offset-0 col-sm-5 col-md-6 col-md-offset-0">{{'TOTAL_VIP_USERS' | translate}}: <span
class="item-data">{{vm.siteInfo.totalVipUsers}}</span></div>
<div class="info-item col-xs-6 col-xs-offset-0 col-sm-5 col-sm-offset-1 col-md-6 col-md-offset-0 col-md-offset-0">{{'TOTAL_IDLE_USERS' | translate}}: <span
class="item-data">{{vm.siteInfo.totalIdleUsers}}</span></div>
<div class="info-item col-xs-6 col-xs-offset-0 col-sm-5 col-md-6 col-md-offset-0">{{'TOTAL_BANNED_USERS' | translate}}: <span
class="item-data">{{vm.siteInfo.totalBannedUsers}}</span></div>
<div class="info-item col-xs-6 col-xs-offset-0 col-sm-5 col-sm-offset-1 col-md-6 col-md-offset-0">{{'TOTAL_TORRENTS' | translate}}: <span
class="item-data">{{vm.siteInfo.totalTorrents}}</span></div>
<div class="info-item col-xs-6 col-xs-offset-0 col-sm-5 col-md-6 col-md-offset-0">{{'TOTAL_TORRENTSSIZE' | translate}}: <span

View File

@@ -1934,7 +1934,37 @@ exports.siteInfo = function (req, res) {
});
};
async.parallel([countUsers, countTorrents, totalTorrentsSize, totalUpDown, countForumTopics, totalForumReplies, countVipUsers], function (err, results) {
var countIdleUsers = function (callback) {
User.count({status: 'idle'}, function (err, count) {
if (err) {
callback(err, null);
} else {
callback(null, count);
}
});
};
var countBannedUsers = function (callback) {
User.count({status: 'banned'}, function (err, count) {
if (err) {
callback(err, null);
} else {
callback(null, count);
}
});
};
var countInactiveUsers = function (callback) {
User.count({status: 'inactive'}, function (err, count) {
if (err) {
callback(err, null);
} else {
callback(null, count);
}
});
};
async.parallel([countUsers, countTorrents, totalTorrentsSize, totalUpDown, countForumTopics, totalForumReplies, countVipUsers, countIdleUsers, countBannedUsers, countInactiveUsers], function (err, results) {
if (err) {
return res.status(422).send(err);
} else {
@@ -1948,7 +1978,10 @@ exports.siteInfo = function (req, res) {
totalDownloaded: results[3][0] ? results[3][0].downloaded : 0,
totalForumTopics: results[4],
totalForumReplies: results[5][0] ? results[5][0].replies : 0,
totalVipUsers: results[6]
totalVipUsers: results[6],
totalIdleUsers: results[7],
totalBannedUsers: results[8],
totalInactiveUsers: results[9],
});
}
});