diff --git a/apps/storage.json b/apps/storage.json index 5a69f819c..b2d5bc82e 100644 --- a/apps/storage.json +++ b/apps/storage.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "💾", - "previous": "&pAfoMT2ey5mk4X+ABcHQoliXPQaVaeolnTU6ri5P1UI=.sha256" + "previous": "&mvGTlWKFR5QM/3nb4fJ2WQq0n/gNKvBmhGDkAvb8ki8=.sha256" } diff --git a/apps/storage/app.js b/apps/storage/app.js index 5e865471f..dffc9d5f7 100644 --- a/apps/storage/app.js +++ b/apps/storage/app.js @@ -35,6 +35,17 @@ async function get_names(identities) { `, [JSON.stringify(identities)]); } +async function get_most_follows() { + return query(` + select author, count(*) as count + from messages + where content ->> 'type' = 'contact' and content ->> 'following' = true + group by author + order by count desc + limit 10; + `); +} + function nice_size(bytes) { let value = bytes; let index = 0; @@ -48,12 +59,13 @@ function nice_size(bytes) { async function main() { await app.setDocument('
Finding the top 10 largest feeds...
'); + let most_follows = await get_most_follows(); let total = await get_total(); let identities = await ssb.getAllIdentities(); let following1 = await ssb.following(identities, 1); let following2 = await ssb.following(identities, 2); let biggest = await get_biggest(); - let names = await get_names(biggest.map(x => x.author)); + let names = await get_names([].concat(biggest.map(x => x.author), most_follows.map(x => x.author))); names = Object.fromEntries(names.map(x => [x.author, x.name])); for (let item of biggest) { item.name = names[item.author]; @@ -63,8 +75,12 @@ async function main() { following2[item.author] !== undefined ? 2 : undefined; } + for (let item of most_follows) { + item.name = names[item.author]; + } let html = `\n -Total ${nice_size(total.size)} in ${total.count} accounts.