diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-04-04 21:44:26 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-04-04 21:44:26 +0200 |
| commit | d3a31c89081f7d2d268c53fef64c502407ef42bb (patch) | |
| tree | 0716404c61db49a495f19b31df4b8a57bf6db3b0 /bucky/app/bucky.js | |
| parent | da5de0257fc9c9d8c4c7f589d84ced2ef19b9f04 (diff) | |
user list
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 8ff0b15..74caa66 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -579,6 +579,51 @@ var bucky = module.exports = { next() }) }, + ensureUserThreadCounts: function (req, res, next) { + db.getUserThreadCounts().then(function(counts){ + if (!counts) { + return res.sendStatus(404) + } + res.threadCounts = counts + next() + }) + }, + ensureUserCommentCounts: function (req, res, next) { + db.getUserCommentCounts().then(function(counts){ + if (!counts) { + return res.sendStatus(404) + } + res.commentCounts = counts + next() + }) + }, + ensureUserFileCounts: function (req, res, next) { + db.getUserFileCounts().then(function(counts){ + if (!counts) { + return res.sendStatus(404) + } + res.fileCounts = counts + next() + }) + }, + ensureUserStatistics: function (req, res, next) { + var stats = {} + res.threadCounts.forEach(function(user){ + stats[user.username] = stats[user.username] || {} + stats[user.username].threads = user.count + }) + res.commentCounts.forEach(function(user){ + stats[user.username] = stats[user.username] || {} + stats[user.username].comments = user.count + }) + res.fileCounts.forEach(function(user){ + stats[user.username] = stats[user.username] || {} + stats[user.username].files = user.count + stats[user.username].fileSize = user.size + }) + res.userStats = stats + next() + }, sanitizeUser: function(req, res, next) { res.user = util.sanitizeUser(res.user) next() |
