git ssb

10+

Matt McKegg / patchwork



Tree: 99aead0a4c4797532b2986ba64d8c30f3d3c5993

Files: 99aead0a4c4797532b2986ba64d8c30f3d3c5993 / modules / obs-recently-updated-feeds.js

964 bytesRaw
1var pull = require('pull-stream')
2var pullCat = require('pull-cat')
3var computed = require('@mmckegg/mutant/computed')
4var MutantPullReduce = require('../lib/mutant-pull-reduce')
5var plugs = require('patchbay/plugs')
6var sbot_log = plugs.first(exports.sbot_log = [])
7var throttle = require('@mmckegg/mutant/throttle')
8var hr = 60 * 60 * 1000
9
10exports.obs_recently_updated_feeds = function (limit) {
11 var stream = pull(
12 pullCat([
13 sbot_log({reverse: true, limit: limit || 500}),
14 sbot_log({old: false})
15 ])
16 )
17
18 var result = MutantPullReduce(stream, (result, msg) => {
19 if (msg.value.timestamp && Date.now() - msg.value.timestamp < 24 * hr) {
20 result.add(msg.value.author)
21 }
22 return result
23 }, {
24 startValue: new Set(),
25 nextTick: true
26 })
27
28 var instance = throttle(result, 2000)
29 instance.sync = result.sync
30
31 instance.has = function (value) {
32 return computed(instance, x => x.has(value))
33 }
34
35 return instance
36}
37

Built with git-ssb-web