git ssb

10+

Matt McKegg / patchwork



Commit f8d403078d632490a3a821d929fa54b0f9673a6c

make recent post search wider (7 days, 4000 posts) and cache results

- improves ranking of friends on profiles (show active friends first)
Matt McKegg committed on 4/7/2017, 1:59:06 AM
Parent: 396cc6e6e6fae7fff0c92425e4ef1a14e39b1204

Files changed

modules/page/html/render/public.jschanged
modules/profile/obs/recently-updated.jschanged
modules/page/html/render/public.jsView
@@ -110,9 +110,9 @@
110110
111111 return result
112112
113113 function getSidebar () {
114- var whoToFollow = computed([following, api.profile.obs.recentlyUpdated(200), localPeers], (following, recent, peers) => {
114 + var whoToFollow = computed([following, api.profile.obs.recentlyUpdated(), localPeers], (following, recent, peers) => {
115115 return Array.from(recent).filter(x => x !== id && !following.has(x) && !peers.includes(x)).slice(0, 10)
116116 })
117117 return [
118118 h('button -pub -full', {
modules/profile/obs/recently-updated.jsView
@@ -12,32 +12,39 @@
1212
1313 exports.gives = nest('profile.obs.recentlyUpdated')
1414
1515 exports.create = function (api) {
16- return nest('profile.obs.recentlyUpdated', function (limit) {
16 + var instance = null
17 +
18 + return nest('profile.obs.recentlyUpdated', function () {
19 + load()
20 + return instance
21 + })
22 +
23 + function load () {
24 + if (instance) return
25 +
1726 var stream = pull(
1827 pullCat([
19- api.sbot.pull.feed({reverse: true, limit: limit || 500}),
28 + api.sbot.pull.feed({reverse: true, limit: 4000}),
2029 api.sbot.pull.feed({old: false})
2130 ])
2231 )
2332
2433 var result = MutantPullReduce(stream, (result, msg) => {
25- if (msg.value.timestamp && Date.now() - msg.value.timestamp < 24 * hr) {
34 + if (msg.value.timestamp && Date.now() - msg.value.timestamp < (7 * 24 * hr)) {
2635 result.add(msg.value.author)
2736 }
2837 return result
2938 }, {
3039 startValue: new Set(),
3140 nextTick: true
3241 })
3342
34- var instance = throttle(result, 2000)
43 + instance = throttle(result, 2000)
3544 instance.sync = result.sync
3645
3746 instance.has = function (value) {
3847 return computed(instance, x => x.has(value))
3948 }
40-
41- return instance
42- })
49 + }
4350 }

Built with git-ssb-web