forked from cory/tildefriends
storage: Show totals, too.
This commit is contained in:
parent
4350c7b7a9
commit
4c2fa2c1b3
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "💾",
|
"emoji": "💾",
|
||||||
"previous": "&vC6kbwiCRkFMMrapQEQ+SprSbItL/+Tm9AC4eigk48I=.sha256"
|
"previous": "&pAfoMT2ey5mk4X+ABcHQoliXPQaVaeolnTU6ri5P1UI=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
async function get_names(identities) {
|
||||||
return query(`
|
return query(`
|
||||||
SELECT author, name FROM (
|
SELECT author, name FROM (
|
||||||
@ -42,6 +48,7 @@ function nice_size(bytes) {
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await app.setDocument('<p style="color: #fff">Finding the top 10 largest feeds...</p>');
|
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 identities = await ssb.getAllIdentities();
|
||||||
let following1 = await ssb.following(identities, 1);
|
let following1 = await ssb.following(identities, 1);
|
||||||
let following2 = await ssb.following(identities, 2);
|
let following2 = await ssb.following(identities, 2);
|
||||||
@ -63,9 +70,13 @@ async function main() {
|
|||||||
html += `<li>
|
html += `<li>
|
||||||
<span style="color: #888">${nice_size(item.size)}</span>
|
<span style="color: #888">${nice_size(item.size)}</span>
|
||||||
<a target="_top" href="/~core/ssb/#${encodeURI(item.author)}">${item.name ?? item.author}</a>
|
<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);
|
await app.setDocument(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user