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.js | changed |
modules/profile/obs/recently-updated.js | changed |
modules/page/html/render/public.js | ||
---|---|---|
@@ -110,9 +110,9 @@ | ||
110 | 110 … | |
111 | 111 … | return result |
112 | 112 … | |
113 | 113 … | 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) => { | |
115 | 115 … | return Array.from(recent).filter(x => x !== id && !following.has(x) && !peers.includes(x)).slice(0, 10) |
116 | 116 … | }) |
117 | 117 … | return [ |
118 | 118 … | h('button -pub -full', { |
modules/profile/obs/recently-updated.js | ||
---|---|---|
@@ -12,32 +12,39 @@ | ||
12 | 12 … | |
13 | 13 … | exports.gives = nest('profile.obs.recentlyUpdated') |
14 | 14 … | |
15 | 15 … | 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 … | + | |
17 | 26 … | var stream = pull( |
18 | 27 … | pullCat([ |
19 | - api.sbot.pull.feed({reverse: true, limit: limit || 500}), | |
28 … | + api.sbot.pull.feed({reverse: true, limit: 4000}), | |
20 | 29 … | api.sbot.pull.feed({old: false}) |
21 | 30 … | ]) |
22 | 31 … | ) |
23 | 32 … | |
24 | 33 … | 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)) { | |
26 | 35 … | result.add(msg.value.author) |
27 | 36 … | } |
28 | 37 … | return result |
29 | 38 … | }, { |
30 | 39 … | startValue: new Set(), |
31 | 40 … | nextTick: true |
32 | 41 … | }) |
33 | 42 … | |
34 | - var instance = throttle(result, 2000) | |
43 … | + instance = throttle(result, 2000) | |
35 | 44 … | instance.sync = result.sync |
36 | 45 … | |
37 | 46 … | instance.has = function (value) { |
38 | 47 … | return computed(instance, x => x.has(value)) |
39 | 48 … | } |
40 | - | |
41 | - return instance | |
42 | - }) | |
49 … | + } | |
43 | 50 … | } |
Built with git-ssb-web