storage: Show totals, too.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 16m26s

This commit is contained in:
Cory McWilliams 2024-11-26 16:05:28 -05:00
parent 4350c7b7a9
commit 4c2fa2c1b3
2 changed files with 14 additions and 3 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "💾",
"previous": "&vC6kbwiCRkFMMrapQEQ+SprSbItL/+Tm9AC4eigk48I=.sha256"
"previous": "&pAfoMT2ey5mk4X+ABcHQoliXPQaVaeolnTU6ri5P1UI=.sha256"
}

View File

@ -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('<p style="color: #fff">Finding the top 10 largest feeds...</p>');
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 += `<li>
<span style="color: #888">${nice_size(item.size)}</span>
<a target="_top" href="/~core/ssb/#${encodeURI(item.author)}">${item.name ?? item.author}</a>
</li>\n`;
</li>
\n`;
}
html += '</ol>\n';
html += `
</ol>
<p>Total <span style="color: #888">${nice_size(total.size)}</span> in ${total.count} accounts.</p>
`;
await app.setDocument(html);
}