diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-01-25 02:15:48 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-01-25 02:15:48 +0100 |
| commit | f8055775f3ac74e9e6054aef102673cefcf27986 (patch) | |
| tree | 6c7c302746db594ff0d61863f533633c7259de33 /bucky/app/bucky.js | |
| parent | 3975b8e7e2841298da1ad497ffe29ba004b55ec2 (diff) | |
more on profile
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 76c543a..2a362b5 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -312,6 +312,46 @@ var bucky = module.exports = { next() }) }, + ensureThreadsForUser: function (req, res, next){ + var username = res.user.username + var limit = parseInt(req.params.limit) || 10 + var offset = parseInt(req.params.offset) || 0 + if (! username) { + res.sendStatus(404) + } + db.getThreadsForUser(username, limit, offset).then(function(threads){ + res.threads = threads + res.threads_ids = res.threads.pluck("id").sort() + res.keywords = _.uniq(res.threads.pluck("keyword")) + next() + }) + }, + ensureTopThreadsForUser: function (req, res, next){ + var username = res.user.username + var limit = parseInt(req.params.limit) || 10 + var offset = parseInt(req.params.offset) || 0 + if (! username) { + res.sendStatus(404) + } + db.getTopThreadsForUser(username, limit, offset).then(function(top_threads){ + res.topThreads = top_threads + res.topThreads_ids = res.topThreads.pluck("id").sort() + res.topKeywords = _.uniq(res.topThreads.pluck("keyword")) + next() + }) + }, + ensureCommentsForUser: function (req, res, next){ + db.getCommentsForUser(res.user.username).then(function(comments){ + res.comments = comments || [] + next() + }) + }, + ensureFilesForUser: function (req, res, next){ + db.getFilesForUser(res.user.username).then(function(files){ + res.files = files || [] + next() + }) + }, createKeyword: function (req, res, next){ if (! req.body.keyword || ! req.body.keyword.length) { res.json({ error: "no keyword" }) |
