diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-02-01 18:03:14 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-02-01 18:03:14 -0500 |
commit | 21bd44fdc84971d44fcfb4d40d408e5baf3ba1e7 (patch) | |
tree | 52160a234e4e4f0af8556a74418c489c52d4a4a2 /lib | |
parent | dc008e9096b97befaeba9eb684dbcd8d872c2a38 (diff) | |
download | patchfoo-21bd44fdc84971d44fcfb4d40d408e5baf3ba1e7.tar.gz patchfoo-21bd44fdc84971d44fcfb4d40d408e5baf3ba1e7.zip |
Sorted logbook joined streams
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/lib/serve.js b/lib/serve.js index b61505b..21f08ac 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -25,6 +25,9 @@ var split = require('pull-split') var utf8 = require('pull-utf8-decoder') var webresolve = require('ssb-web-resolver') var Url = require('url') +var many = require('pull-many') +var merge = require('pull-merge') +var pSort = require('pull-sort') module.exports = Serve @@ -576,28 +579,41 @@ Serve.prototype.home = function () { ) } +compareMsgs = function(a, b) { + return -(a.value.timestamp - b.value.timestamp) +} + Serve.prototype.logbook = function (ext) { + var channel = "logbook" var q = this.query + var gt = Number(q.gt) || -Infinity + var lt = Number(q.lt) || Date.now() var opts = { + sortByTimestamp: q.sort === 'claimed', reverse: !q.forwards, - //sortByTimestamp: q.sort === 'claimed', - sortByTimestamp: q.sort || 'claimed', - lt: Number(q.lt) || Date.now(), - gt: Number(q.gt) || -Infinity, + lt: lt, + gt: gt, + channel: channel, filter: q.filter, } + var wordSearchQ = String(channel).toLowerCase() + var opts2 = { + query: wordSearchQ, + } + var outOpts = {} pull( - this.app.createLogStream(opts), - pull.filter(msg => { - return !msg.value.content.vote - }), + merge( + pull(this.app.streamChannel(opts), pSort(compareMsgs)), + pull(this.app.sbot.search.query(opts2), pSort(compareMsgs)), + compareMsgs + ), this.renderThreadPaginated(opts, null, q), this.wrapMessages(), - this.wrapPublic(), - this.wrapPage('public'), + this.wrapChannel(channel), + this.wrapPage('#' + channel), this.respondSink(200, { - 'Content-Type': ctype(ext) + 'Content-Type': ctype('html') }) ) } |