summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index 8d9839f..ab153f9 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -227,6 +227,10 @@ var bucky = module.exports = {
next()
})
},
+ buryThread: function (req, res, next){
+ res.thread.set('lastmodified', util.now() - (14 * 86400))
+ res.thread.save().then( () => next() )
+ },
// ensureInterestedUsers: function(req, res, next){
// // given a thread, find people who might be interested in it
// // - other people who have been in threads with you
@@ -296,6 +300,12 @@ var bucky = module.exports = {
next()
})
},
+ ensureLatestKeywordThreads: function (req, res, next){
+ db.getLatestKeywordThreads().then(function(threads){
+ res.threads = threads
+ next()
+ })
+ },
ensureThreadGroups: function (req, res, next){
db.getThreadGroups().then(function(threadGroups){
res.threadGroups = threadGroups
@@ -571,6 +581,60 @@ var bucky = module.exports = {
}
})
},
+ ensureUserlist: function (req, res, next){
+ db.getUsers().then(function(users){
+ if (! users) {
+ return res.sendStatus(404)
+ }
+ res.users = users
+ 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()