From 4c2fa2c1b362b1d79207e563b002f33df4e090f3 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Tue, 26 Nov 2024 16:05:28 -0500 Subject: [PATCH] storage: Show totals, too. --- apps/storage.json | 2 +- apps/storage/app.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/storage.json b/apps/storage.json index fda4f6384..5a69f819c 100644 --- a/apps/storage.json +++ b/apps/storage.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "💾", - "previous": "&vC6kbwiCRkFMMrapQEQ+SprSbItL/+Tm9AC4eigk48I=.sha256" + "previous": "&pAfoMT2ey5mk4X+ABcHQoliXPQaVaeolnTU6ri5P1UI=.sha256" } diff --git a/apps/storage/app.js b/apps/storage/app.js index f5b47c89f..5e865471f 100644 --- a/apps/storage/app.js +++ b/apps/storage/app.js @@ -13,6 +13,12 @@ async function get_biggest() { `); } +async function get_total() { + return (await query(` + select sum(length(content)) as size, count(distinct author) as count from messages; + `))[0]; +} + async function get_names(identities) { return query(` SELECT author, name FROM ( @@ -42,6 +48,7 @@ function nice_size(bytes) { async function main() { await app.setDocument('

Finding the top 10 largest feeds...

'); + let total = await get_total(); let identities = await ssb.getAllIdentities(); let following1 = await ssb.following(identities, 1); let following2 = await ssb.following(identities, 2); @@ -63,9 +70,13 @@ async function main() { html += `
  • ${nice_size(item.size)} ${item.name ?? item.author} -
  • \n`; + + \n`; } - html += '\n'; + html += ` + +

    Total ${nice_size(total.size)} in ${total.count} accounts.

    + `; await app.setDocument(html); }