ssb: Stop breaking up the news queries into chunks. It sometimes produced incorrect results, and it is not necessary if we're fast enough.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 20m50s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 20m50s
This commit is contained in:
parent
83e00763ea
commit
71ff604f90
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&wzVxQjLzBbwClkI3GB2t85i3pJxRcE1RnCXzC/TbfAw=.sha256"
|
"previous": "&xT+7rr+XiiHu6hRK+cf15/CCECDyMIp+skvPByaa+eE=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -106,50 +106,43 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
[this.hash.substring(1)]
|
[this.hash.substring(1)]
|
||||||
);
|
);
|
||||||
} else if (this.hash.startsWith('##')) {
|
} else if (this.hash.startsWith('##')) {
|
||||||
let promises = [];
|
result = await tfrpc.rpc.query(
|
||||||
const k_following_limit = 256;
|
`
|
||||||
for (let i = 0; i < this.following.length; i += k_following_limit) {
|
WITH
|
||||||
promises.push(
|
all_news AS (
|
||||||
tfrpc.rpc.query(
|
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
`
|
FROM messages
|
||||||
WITH
|
JOIN json_each(?) AS following ON messages.author = following.value
|
||||||
all_news AS (
|
WHERE messages.content ->> 'channel' = ?4
|
||||||
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
UNION
|
||||||
FROM messages
|
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
JOIN json_each(?) AS following ON messages.author = following.value
|
FROM messages_fts(?5)
|
||||||
WHERE messages.content ->> 'channel' = ?4
|
JOIN messages ON messages.rowid = messages_fts.rowid
|
||||||
UNION
|
JOIN json_each(?1) AS following ON messages.author = following.value
|
||||||
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
JOIN json_tree(messages.content, '$.mentions') AS mention ON mention.value = '#' || ?4),
|
||||||
FROM messages_fts(?5)
|
news AS (SELECT * FROM all_news
|
||||||
JOIN messages ON messages.rowid = messages_fts.rowid
|
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
||||||
JOIN json_each(?1) AS following ON messages.author = following.value
|
ORDER BY all_news.timestamp DESC LIMIT 20)
|
||||||
JOIN json_tree(messages.content, '$.mentions') AS mention ON mention.value = '#' || ?4),
|
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
news AS (SELECT * FROM all_news
|
FROM news
|
||||||
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
JOIN messages_refs ON news.id = messages_refs.ref
|
||||||
ORDER BY all_news.timestamp DESC LIMIT 20)
|
JOIN messages ON messages_refs.message = messages.id
|
||||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
UNION
|
||||||
FROM news
|
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
JOIN messages_refs ON news.id = messages_refs.ref
|
FROM news
|
||||||
JOIN messages ON messages_refs.message = messages.id
|
JOIN messages_refs ON news.id = messages_refs.message
|
||||||
UNION
|
JOIN messages ON messages_refs.ref = messages.id
|
||||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
UNION
|
||||||
FROM news
|
SELECT TRUE AS is_primary, news.* FROM news
|
||||||
JOIN messages_refs ON news.id = messages_refs.message
|
`,
|
||||||
JOIN messages ON messages_refs.ref = messages.id
|
[
|
||||||
UNION
|
JSON.stringify(this.following),
|
||||||
SELECT TRUE AS is_primary, news.* FROM news
|
start_time,
|
||||||
`,
|
end_time,
|
||||||
[
|
this.hash.substring(2),
|
||||||
JSON.stringify(this.following.slice(i, i + k_following_limit)),
|
'"#' + this.hash.substring(2).replace('"', '""') + '"',
|
||||||
start_time,
|
]
|
||||||
end_time,
|
);
|
||||||
this.hash.substring(2),
|
|
||||||
'"#' + this.hash.substring(2).replace('"', '""') + '"',
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
result = [].concat(...(await Promise.all(promises)));
|
|
||||||
} else if (this.hash == '#🔐') {
|
} else if (this.hash == '#🔐') {
|
||||||
result = await tfrpc.rpc.query(
|
result = await tfrpc.rpc.query(
|
||||||
`
|
`
|
||||||
@ -167,28 +160,28 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
} else {
|
} else {
|
||||||
result = await tfrpc.rpc.query(
|
result = await tfrpc.rpc.query(
|
||||||
`
|
`
|
||||||
WITH
|
WITH
|
||||||
all_news AS (
|
all_news AS (
|
||||||
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
FROM messages
|
FROM messages
|
||||||
JOIN json_each(?) AS following ON messages.author = following.value
|
JOIN json_each(?) AS following ON messages.author = following.value
|
||||||
WHERE timestamp >= 0 AND timestamp < ?3),
|
WHERE timestamp >= 0 AND timestamp < ?3),
|
||||||
news AS (
|
news AS (
|
||||||
SELECT * FROM all_news
|
SELECT * FROM all_news
|
||||||
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
WHERE (?2 IS NULL OR all_news.timestamp >= ?2) AND all_news.timestamp < ?3
|
||||||
ORDER BY timestamp DESC LIMIT 20
|
ORDER BY timestamp DESC LIMIT 20
|
||||||
)
|
)
|
||||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
FROM news
|
FROM news
|
||||||
JOIN messages_refs ON news.id = messages_refs.ref
|
JOIN messages_refs ON news.id = messages_refs.ref
|
||||||
JOIN messages ON messages_refs.message = messages.id
|
JOIN messages ON messages_refs.message = messages.id
|
||||||
UNION
|
UNION
|
||||||
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
FROM news
|
FROM news
|
||||||
JOIN messages_refs ON news.id = messages_refs.message
|
JOIN messages_refs ON news.id = messages_refs.message
|
||||||
JOIN messages ON messages_refs.ref = messages.id
|
JOIN messages ON messages_refs.ref = messages.id
|
||||||
UNION
|
UNION
|
||||||
SELECT TRUE AS is_primary, news.* FROM news
|
SELECT TRUE AS is_primary, news.* FROM news
|
||||||
`,
|
`,
|
||||||
[JSON.stringify(this.following), start_time, end_time]
|
[JSON.stringify(this.following), start_time, end_time]
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user