Experiments in updating faster.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3845 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
ac0482d7f5
commit
ffaaec5b37
@ -1 +1 @@
|
|||||||
{"type":"tildefriends-app","files":{"app.js":"&xynMjji35hfaE7anTfEM8uAg33s4Y2ffkbq1rPU4dqY=.sha256","index.html":"&xCI4SATYvlJkVX5EdlRROoDSMWlajF+wDFrWSUYZqd8=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&kIpc5B2dt4oefsTgNASz2cVte3WRO0k2NCYJYRzu/MA=.sha256","tf.js":"&WvteLAg4G92YOUO3/B36kmar5lqFq8Pil4rsy7uFNDY=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&X+zVM6t/QOUF/s0mqWWUWD7tMjzcCaflTy3a8zFAEH8=.sha256"}}
|
{"type":"tildefriends-app","files":{"app.js":"&bqEYTfdwANwoIjnvcuhdPQHgNdEfyUGQSB5pmGg6408=.sha256","index.html":"&xCI4SATYvlJkVX5EdlRROoDSMWlajF+wDFrWSUYZqd8=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&kIpc5B2dt4oefsTgNASz2cVte3WRO0k2NCYJYRzu/MA=.sha256","tf.js":"&WvteLAg4G92YOUO3/B36kmar5lqFq8Pil4rsy7uFNDY=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&X+zVM6t/QOUF/s0mqWWUWD7tMjzcCaflTy3a8zFAEH8=.sha256"}}
|
@ -337,7 +337,6 @@ async function getVotes(db, id) {
|
|||||||
f.votes = [].concat(votes, f.votes).slice(0, k_votes_max);
|
f.votes = [].concat(votes, f.votes).slice(0, k_votes_max);
|
||||||
var j = JSON.stringify(f);
|
var j = JSON.stringify(f);
|
||||||
if (o != j) {
|
if (o != j) {
|
||||||
print('set', id + ':votes');
|
|
||||||
await db.set(id + ":votes", j);
|
await db.set(id + ":votes", j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,15 +368,44 @@ core.register('onConnectionsChanged', async function() {
|
|||||||
await app.postMessage({connections: connections});
|
await app.postMessage({connections: connections});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function updateSequences(db) {
|
||||||
|
var k_batch_max = 100;
|
||||||
|
var changes = {};
|
||||||
|
var keys = Object.keys(g_sequence);
|
||||||
|
for (var i = 0; i < keys.length; i += k_batch_max) {
|
||||||
|
var ids_batch = keys.slice(i, Math.min(i + k_batch_max, keys.length));
|
||||||
|
await ssb.sqlStream(
|
||||||
|
"SELECT "+
|
||||||
|
" author, "+
|
||||||
|
" MAX(sequence) AS sequence "+
|
||||||
|
"FROM messages "+
|
||||||
|
"WHERE "+
|
||||||
|
" author IN (" + ids_batch.map(x => '?').join(", ") + ")",
|
||||||
|
ids_batch,
|
||||||
|
function(row) {
|
||||||
|
if (g_sequence[row.author] != row.sequence) {
|
||||||
|
g_sequence[row.author] = row.sequence;
|
||||||
|
changes[row.author] = row.sequence;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
async function refresh(selected) {
|
async function refresh(selected) {
|
||||||
var timing = [];
|
var timing = [];
|
||||||
timing.push({name: 'start', time: new Date()});
|
timing.push({name: 'start', time: new Date()});
|
||||||
g_following_cache = {};
|
g_following_cache = {};
|
||||||
g_following_deep_cache = {};
|
g_following_deep_cache = {};
|
||||||
g_sequence = {};
|
|
||||||
await app.postMessage({clear: true});
|
await app.postMessage({clear: true});
|
||||||
var whoami = await ssb.whoami();
|
var whoami = await ssb.whoami();
|
||||||
var db = await database("ssb");
|
var db = await database("ssb");
|
||||||
|
g_sequence = {};
|
||||||
|
try {
|
||||||
|
g_sequence = JSON.parse(await db.get('sequence'));
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
await updateSequences(db);
|
||||||
timing.push({name: 'init', time: new Date()});
|
timing.push({name: 'init', time: new Date()});
|
||||||
var blocked = await blocking(db, whoami);
|
var blocked = await blocking(db, whoami);
|
||||||
timing.push({name: 'blocked', time: new Date()});
|
timing.push({name: 'blocked', time: new Date()});
|
||||||
@ -437,6 +465,7 @@ async function refresh(selected) {
|
|||||||
timing.push({name: 'following', time: new Date()});
|
timing.push({name: 'following', time: new Date()});
|
||||||
await app.postMessage({blocking: {id: whoami, users: [...(g_blocking_cache[whoami] || [])]}});
|
await app.postMessage({blocking: {id: whoami, users: [...(g_blocking_cache[whoami] || [])]}});
|
||||||
timing.push({name: 'send_blocking', time: new Date()});
|
timing.push({name: 'send_blocking', time: new Date()});
|
||||||
|
await db.set('sequence', JSON.stringify(g_sequence));
|
||||||
|
|
||||||
var times = {};
|
var times = {};
|
||||||
var previous = null;
|
var previous = null;
|
||||||
@ -444,7 +473,6 @@ async function refresh(selected) {
|
|||||||
times[t.name] = (t.time - (previous || t).time) / 1000.0 + ' s';
|
times[t.name] = (t.time - (previous || t).time) / 1000.0 + ' s';
|
||||||
previous = t;
|
previous = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
await app.postMessage({ready: true, times: times});
|
await app.postMessage({ready: true, times: times});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user