diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-06 12:07:22 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-06 12:07:22 -0400 |
| commit | 5e5cdd7e3758412851fffa56a9786ffa5d751e40 (patch) | |
| tree | 97b567ba0bfa1700a7db5b03d276bb9f4c108484 /lib/bucky.js | |
| parent | abe12120374d07cf5f87192964a9d1c10741e475 (diff) | |
getting colors from keywords
Diffstat (limited to 'lib/bucky.js')
| -rw-r--r-- | lib/bucky.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/bucky.js b/lib/bucky.js index ef6fbbc..9a43c0d 100644 --- a/lib/bucky.js +++ b/lib/bucky.js @@ -1,4 +1,5 @@ var db = require('./db') +var _ = require('lodash') var bucky = module.exports = { @@ -8,6 +9,7 @@ var bucky = module.exports = { db.getLatestThreads().then(function(threads){ res.threads = threads res.threads_ids = res.threads.pluck("id").sort() + res.keywords = _.uniq(res.threads.pluck("keyword")) next() }) }, @@ -33,6 +35,26 @@ var bucky = module.exports = { next() }) }, + ensureKeywordsForThreads: function (req, res, next){ + db.getKeywords(res.keywords).then(function(keywords){ + var lookup = {} + keywords.forEach(function(k){ + lookup[k.get('keyword')] = k + }) + console.log(keywords) + res.threads.forEach(function(t){ + var kw = t.get('keyword') + if (! kw) return + var k = lookup[kw] + if (! k) return + if (! t.get("color")) { + t.set("color", k.get("color")) + console.log(k.get("color")) + } + }) + next() + }) + }, ensureHootbox: function (req, res, next){ db.getCommentsForThread(1, 9).then(function(hootbox){ res.hootbox = hootbox |
