ssb: Add a lookup table of max sequence and timestamp per account.f
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 20m47s

This commit is contained in:
2025-01-22 19:19:50 -05:00
parent c7a8ce7060
commit c728e05032
4 changed files with 27 additions and 22 deletions

View File

@ -402,10 +402,9 @@ class TfElement extends LitElement {
async fetch_user_info(users) {
let info = await tfrpc.rpc.query(
`
SELECT messages.author, MAX(messages.sequence) AS max_seq, MAX(timestamp) AS max_ts FROM messages
SELECT messages_stats.author, messages_stats.max_sequence, messages_stats.max_timestamp AS max_ts FROM messages_stats
JOIN json_each(?) AS following
ON messages.author = following.value
GROUP BY messages.author
ON messages_stats.author = following.value
`,
[JSON.stringify(Object.keys(users))]
);

View File

@ -190,11 +190,7 @@ class TfTabNewsFeedElement extends LitElement {
UNION
SELECT TRUE AS is_primary, news.* FROM news
`,
[
JSON.stringify(this.following),
start_time,
end_time,
]
[JSON.stringify(this.following), start_time, end_time]
);
}
this.time_loading = undefined;
@ -223,9 +219,7 @@ class TfTabNewsFeedElement extends LitElement {
let last_start_time = this.time_range[0];
more = await this.fetch_messages(null, last_start_time);
this.update_time_range_from_messages(
more.filter(
(x) => x.timestamp < last_start_time
)
more.filter((x) => x.timestamp < last_start_time)
);
this.messages = await this.decrypt([...more, ...this.messages]);
} finally {
@ -315,14 +309,9 @@ class TfTabNewsFeedElement extends LitElement {
let start_time = now - 24 * 60 * 60 * 1000;
this.start_time = start_time;
this.time_range = [this.start_time, now + 24 * 60 * 60 * 1000];
messages = await this.fetch_messages(
null,
this.time_range[1]
);
messages = await this.fetch_messages(null, this.time_range[1]);
this.update_time_range_from_messages(
messages.filter(
(x) => x.timestamp < this.time_range[1]
)
messages.filter((x) => x.timestamp < this.time_range[1])
);
messages = await this.decrypt(messages);
} finally {
@ -330,7 +319,9 @@ class TfTabNewsFeedElement extends LitElement {
}
this.messages = this.merge_messages(this.messages, messages);
this.time_loading = undefined;
console.log(`loading messages done for ${self.whoami} in ${(new Date() - start_time) / 1000}s`);
console.log(
`loading messages done for ${self.whoami} in ${(new Date() - start_time) / 1000}s`
);
}
mark_all_read() {