Hitting some limit with following too many people. Working around it.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4610 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
6ef14d985d
commit
aa10ab69f6
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🐌",
|
"emoji": "🐌",
|
||||||
"previous": "&qvm+scemENl4DobpOoh/UyILGvvx5NbcPJKTU3CswSE=.sha256"
|
"previous": "&tx4iQew0sHvZW3YAEx8y2Qr8m+MhoNdxs/5+1Rx4s7Y=.sha256"
|
||||||
}
|
}
|
@ -212,8 +212,8 @@ class TfElement extends LitElement {
|
|||||||
let whoami = this.whoami;
|
let whoami = this.whoami;
|
||||||
let tags = this.load_recent_tags();
|
let tags = this.load_recent_tags();
|
||||||
let following = await tfrpc.rpc.following([whoami], 2);
|
let following = await tfrpc.rpc.following([whoami], 2);
|
||||||
console.log(following);
|
|
||||||
let users = {};
|
let users = {};
|
||||||
|
let by_count = [];
|
||||||
for (let [id, v] of Object.entries(following)) {
|
for (let [id, v] of Object.entries(following)) {
|
||||||
users[id] = {
|
users[id] = {
|
||||||
following: v.of,
|
following: v.of,
|
||||||
@ -221,7 +221,9 @@ class TfElement extends LitElement {
|
|||||||
followed: v.if,
|
followed: v.if,
|
||||||
blocked: v.ib,
|
blocked: v.ib,
|
||||||
};
|
};
|
||||||
|
by_count.push({count: v.of, id: id});
|
||||||
}
|
}
|
||||||
|
console.log(by_count.sort((x, y) => y.count - x.count).slice(0, 20));
|
||||||
users = await this.fetch_about(Object.keys(following).sort(), users);
|
users = await this.fetch_about(Object.keys(following).sort(), users);
|
||||||
this.following = Object.keys(following);
|
this.following = Object.keys(following);
|
||||||
this.users = users;
|
this.users = users;
|
||||||
|
@ -65,34 +65,39 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
this.hash.substring(1),
|
this.hash.substring(1),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
return await tfrpc.rpc.query(
|
let messages = [];
|
||||||
`
|
const k_following_limit = 2048;
|
||||||
WITH news AS (SELECT messages.*
|
for (let i = 0; i < this.following.length; i += k_following_limit) {
|
||||||
FROM messages
|
messages = messages.concat(await tfrpc.rpc.query(
|
||||||
JOIN json_each(?) AS following ON messages.author = following.value
|
`
|
||||||
WHERE messages.timestamp > ? AND messages.timestamp < ?
|
WITH news AS (SELECT messages.*
|
||||||
ORDER BY messages.timestamp DESC)
|
FROM messages
|
||||||
SELECT messages.*
|
JOIN json_each(?) AS following ON messages.author = following.value
|
||||||
FROM news
|
WHERE messages.timestamp > ? AND messages.timestamp < ?
|
||||||
JOIN messages_refs ON news.id = messages_refs.ref
|
ORDER BY messages.timestamp DESC)
|
||||||
JOIN messages ON messages_refs.message = messages.id
|
SELECT messages.*
|
||||||
UNION
|
FROM news
|
||||||
SELECT messages.*
|
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 messages.*
|
||||||
UNION
|
FROM news
|
||||||
SELECT 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 news.* FROM news
|
||||||
this.start_time,
|
`,
|
||||||
/*
|
[
|
||||||
** Don't show messages more than a day into the future to prevent
|
JSON.stringify(this.following.slice(i, i + k_following_limit)),
|
||||||
** messages with far-future timestamps from staying at the top forever.
|
this.start_time,
|
||||||
*/
|
/*
|
||||||
new Date().valueOf() + 24 * 60 * 60 * 1000,
|
** Don't show messages more than a day into the future to prevent
|
||||||
]);
|
** messages with far-future timestamps from staying at the top forever.
|
||||||
|
*/
|
||||||
|
new Date().valueOf() + 24 * 60 * 60 * 1000,
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return messages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +133,7 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async decrypt(messages) {
|
async decrypt(messages) {
|
||||||
|
console.log('decrypt');
|
||||||
let result = [];
|
let result = [];
|
||||||
for (let message of messages) {
|
for (let message of messages) {
|
||||||
let content;
|
let content;
|
||||||
@ -162,7 +168,7 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
if (!this.messages ||
|
if (!this.messages ||
|
||||||
this._messages_hash !== this.hash ||
|
this._messages_hash !== this.hash ||
|
||||||
this._messages_following !== this.following) {
|
this._messages_following !== this.following) {
|
||||||
console.log(`loading messages for ${this.whoami}`);
|
console.log(`loading messages for ${this.whoami} (following ${this.following.length})`);
|
||||||
let self = this;
|
let self = this;
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
this._messages_hash = this.hash;
|
this._messages_hash = this.hash;
|
||||||
|
Loading…
Reference in New Issue
Block a user