This commit is contained in:
parent
e1d93c003c
commit
af6091760c
@ -408,9 +408,10 @@ ${JSON.stringify(mention, null, 2)}</pre
|
|||||||
>
|
>
|
||||||
<tf-user id=${self.message.author} .users=${self.users}></tf-user>
|
<tf-user id=${self.message.author} .users=${self.users}></tf-user>
|
||||||
<span style="padding-right: 8px"
|
<span style="padding-right: 8px"
|
||||||
><a tfarget="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a> ${new Date(
|
><a tfarget="_top" href=${'#' + encodeURIComponent(self.message.id)}
|
||||||
self.message.timestamp
|
>%</a
|
||||||
).toLocaleString()}</span
|
>
|
||||||
|
${new Date(self.message.timestamp).toLocaleString()}</span
|
||||||
>
|
>
|
||||||
${raw_button} ${self.format == 'raw' ? self.render_raw() : inner}
|
${raw_button} ${self.format == 'raw' ? self.render_raw() : inner}
|
||||||
${self.render_votes()}
|
${self.render_votes()}
|
||||||
@ -449,7 +450,9 @@ ${JSON.stringify(mention, null, 2)}</pre
|
|||||||
class="w3-card-4 w3-theme-d4 w3-border-theme"
|
class="w3-card-4 w3-theme-d4 w3-border-theme"
|
||||||
style="margin-top: 8px; padding: 16px; overflow-wrap: anywhere"
|
style="margin-top: 8px; padding: 16px; overflow-wrap: anywhere"
|
||||||
>
|
>
|
||||||
<a target="_top" href=${'#' + encodeURIComponent(this.message.id)}>${this.message.id}</a>
|
<a target="_top" href=${'#' + encodeURIComponent(this.message.id)}
|
||||||
|
>${this.message.id}</a
|
||||||
|
>
|
||||||
(placeholder)
|
(placeholder)
|
||||||
<div>${this.render_votes()}</div>
|
<div>${this.render_votes()}</div>
|
||||||
${(this.message.child_messages || []).map(
|
${(this.message.child_messages || []).map(
|
||||||
@ -600,7 +603,11 @@ ${JSON.stringify(content, null, 2)}</pre
|
|||||||
${is_encrypted}
|
${is_encrypted}
|
||||||
<span style="flex: 1"></span>
|
<span style="flex: 1"></span>
|
||||||
<span style="padding-right: 8px"
|
<span style="padding-right: 8px"
|
||||||
><a target="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a>
|
><a
|
||||||
|
target="_top"
|
||||||
|
href=${'#' + encodeURIComponent(self.message.id)}
|
||||||
|
>%</a
|
||||||
|
>
|
||||||
${new Date(this.message.timestamp).toLocaleString()}</span
|
${new Date(this.message.timestamp).toLocaleString()}</span
|
||||||
>
|
>
|
||||||
<span>${raw_button}</span>
|
<span>${raw_button}</span>
|
||||||
@ -643,7 +650,11 @@ ${JSON.stringify(content, null, 2)}</pre
|
|||||||
${is_encrypted}
|
${is_encrypted}
|
||||||
<span style="flex: 1"></span>
|
<span style="flex: 1"></span>
|
||||||
<span style="padding-right: 8px"
|
<span style="padding-right: 8px"
|
||||||
><a target="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a>
|
><a
|
||||||
|
target="_top"
|
||||||
|
href=${'#' + encodeURIComponent(self.message.id)}
|
||||||
|
>%</a
|
||||||
|
>
|
||||||
${new Date(this.message.timestamp).toLocaleString()}</span
|
${new Date(this.message.timestamp).toLocaleString()}</span
|
||||||
>
|
>
|
||||||
<span>${raw_button}</span>
|
<span>${raw_button}</span>
|
||||||
@ -733,7 +744,11 @@ ${JSON.stringify(content, null, 2)}</pre
|
|||||||
<tf-user id=${this.message.author} .users=${this.users}></tf-user>
|
<tf-user id=${this.message.author} .users=${this.users}></tf-user>
|
||||||
<span style="flex: 1"></span>
|
<span style="flex: 1"></span>
|
||||||
<span style="padding-right: 8px"
|
<span style="padding-right: 8px"
|
||||||
><a target="_top" href=${'#' + encodeURIComponent(self.message.id)}>%</a>
|
><a
|
||||||
|
target="_top"
|
||||||
|
href=${'#' + encodeURIComponent(self.message.id)}
|
||||||
|
>%</a
|
||||||
|
>
|
||||||
${new Date(this.message.timestamp).toLocaleString()}</span
|
${new Date(this.message.timestamp).toLocaleString()}</span
|
||||||
>
|
>
|
||||||
<span>${raw_button}</span>
|
<span>${raw_button}</span>
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
async function query(sql, args) {
|
async function query(sql, args) {
|
||||||
let rows = [];
|
let rows = [];
|
||||||
await ssb.sqlAsync(sql, args ?? [], function (row) {
|
await ssb.sqlAsync(sql, args ?? [], function (row) {
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
});
|
});
|
||||||
return rows;;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get_biggest() {
|
async function get_biggest() {
|
||||||
@ -14,13 +13,16 @@ async function get_biggest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function get_total() {
|
async function get_total() {
|
||||||
return (await query(`
|
return (
|
||||||
|
await query(`
|
||||||
select sum(length(content)) as size, count(distinct author) as count from messages;
|
select sum(length(content)) as size, count(distinct author) as count from messages;
|
||||||
`))[0];
|
`)
|
||||||
|
)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get_names(identities) {
|
async function get_names(identities) {
|
||||||
return query(`
|
return query(
|
||||||
|
`
|
||||||
SELECT author, name FROM (
|
SELECT author, name FROM (
|
||||||
SELECT
|
SELECT
|
||||||
messages.author,
|
messages.author,
|
||||||
@ -32,7 +34,9 @@ async function get_names(identities) {
|
|||||||
json_extract(messages.content, '$.type') = 'about' AND
|
json_extract(messages.content, '$.type') = 'about' AND
|
||||||
content ->> 'about' = messages.author AND name IS NOT NULL)
|
content ->> 'about' = messages.author AND name IS NOT NULL)
|
||||||
WHERE author_rank = 1
|
WHERE author_rank = 1
|
||||||
`, [JSON.stringify(identities)]);
|
`,
|
||||||
|
[JSON.stringify(identities)]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get_most_follows() {
|
async function get_most_follows() {
|
||||||
@ -58,22 +62,32 @@ 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 most_follows = await get_most_follows();
|
let most_follows = await get_most_follows();
|
||||||
let total = await get_total();
|
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);
|
||||||
let biggest = await get_biggest();
|
let biggest = await get_biggest();
|
||||||
let names = await get_names([].concat(biggest.map(x => x.author), most_follows.map(x => x.author)));
|
let names = await get_names(
|
||||||
names = Object.fromEntries(names.map(x => [x.author, x.name]));
|
[].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) {
|
for (let item of biggest) {
|
||||||
item.name = names[item.author];
|
item.name = names[item.author];
|
||||||
item.following =
|
item.following =
|
||||||
identities.indexOf(item.author) != -1 ? 0 :
|
identities.indexOf(item.author) != -1
|
||||||
following1[item.author] !== undefined ? 1 :
|
? 0
|
||||||
following2[item.author] !== undefined ? 2 :
|
: following1[item.author] !== undefined
|
||||||
undefined;
|
? 1
|
||||||
|
: following2[item.author] !== undefined
|
||||||
|
? 2
|
||||||
|
: undefined;
|
||||||
}
|
}
|
||||||
for (let item of most_follows) {
|
for (let item of most_follows) {
|
||||||
item.name = names[item.author];
|
item.name = names[item.author];
|
||||||
@ -108,4 +122,6 @@ async function main() {
|
|||||||
await app.setDocument(html);
|
await app.setDocument(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(function(e) { print(e); });
|
main().catch(function (e) {
|
||||||
|
print(e);
|
||||||
|
});
|
||||||
|
2
docs
2
docs
@ -1 +1 @@
|
|||||||
Subproject commit f17105d473c0174a6608d713295add65c6a82b62
|
Subproject commit a40758cc4bef5ded4d214c2acf1c95e554e20564
|
Loading…
Reference in New Issue
Block a user