Permalink
Browse files

whoops fix incremental / realtime channel index updating

  • Loading branch information...
mmckegg committed Jun 27, 2017
1 parent 6a4dd17 commit 7495ba504a750013427db3c17cf79911bdbe5106
Showing with 6 additions and 7 deletions.
  1. +4 −5 plugs/channel/obs/recent.js
  2. +2 −2 sbot/channels.js
@@ -31,17 +31,16 @@ exports.create = function (api) {
pull(
api.sbot.pull.stream(sbot => sbot.patchwork.channels({live: true})),
pull.drain(msg => {
pull.drain(data => {
channelsLookup.transaction(() => {
for (var channel in msg) {
for (var channel in data) {
var obs = channelsLookup.get(channel)
if (!obs) {
obs = ChannelRef(channel)
channelsLookup.put(channel, obs)
}
var count = msg.count != null ? msg.count : obs.count() + 1
var updatedAt = msg[channel].timestamp
var count = data[channel].count != null ? data[channel].count : obs.count() + 1
var updatedAt = data[channel].timestamp
obs.set({ id: channel, updatedAt, count })
}
})
View
@@ -25,9 +25,9 @@ function map (msg) {
if (msg.value.content && typeof msg.value.content.channel === 'string') {
var channel = msg.value.content.channel
if (channel.length > 0 && channel.length < 30) {
return [{
return {
[channel.replace(/\s/g, '')]: {timestamp: msg.timestamp}
}]
}
}
}
}

0 comments on commit 7495ba5

Please sign in to comment.