forked from cory/tildefriends
Fixing getRecentPostIds for the millionth time.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3721 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
12010a84a3
commit
0cab3e7ed9
@ -1 +1 @@
|
||||
{"type":"tildefriends-app","files":{"app.js":"&jkL7crcAyW2KFUlHb43k+cY6JN9Ee3F0gy6ba4p70kg=.sha256","index.html":"&zwiRwroNQ1SnCsq97zB8dRiGwY4H+ii4ZtuKR385zdI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&taC9THJslxAMy72UIplFjALJx1VHv2l+qfjWoRhhrS4=.sha256","tf-message.js":"&KjVh7zASx0TZtZTsS6lJ7T70K9tyXcf+ink4vK7gSWI=.sha256","tf.js":"&u6n7Eqa1ryFuL9AhlYeJ/WzXYh6zxECKVfhG8/ecRM8=.sha256","commonmark.min.js":"&5x6ek3tFrKTZX6hXNNyFsjmhvrjmWpUkwuuaiyVV1Us=.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"}}
|
||||
{"type":"tildefriends-app","files":{"app.js":"&bKoyBQBiMZinCQUoQIqGpeehKgqkANw8Ns2OYECYW30=.sha256","index.html":"&zwiRwroNQ1SnCsq97zB8dRiGwY4H+ii4ZtuKR385zdI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&taC9THJslxAMy72UIplFjALJx1VHv2l+qfjWoRhhrS4=.sha256","tf-message.js":"&KjVh7zASx0TZtZTsS6lJ7T70K9tyXcf+ink4vK7gSWI=.sha256","tf.js":"&u6n7Eqa1ryFuL9AhlYeJ/WzXYh6zxECKVfhG8/ecRM8=.sha256","commonmark.min.js":"&5x6ek3tFrKTZX6hXNNyFsjmhvrjmWpUkwuuaiyVV1Us=.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"}}
|
@ -150,7 +150,7 @@ function fnv32a(value)
|
||||
}
|
||||
|
||||
async function getRecentPostIds(db, id, ids, limit) {
|
||||
const k_version = 9;
|
||||
const k_version = 10;
|
||||
const k_batch_max = 8;
|
||||
var o = await db.get(id + ':recent_posts');
|
||||
var recent = [];
|
||||
@ -161,7 +161,7 @@ async function getRecentPostIds(db, id, ids, limit) {
|
||||
}
|
||||
var row_id_max = 0;
|
||||
await ssb.sqlStream(
|
||||
"SELECT MAX(rowid) as rowid FROM messages ORDER BY timestamp DESC LIMIT ?",
|
||||
"SELECT MAX(rowid) as rowid FROM messages",
|
||||
[],
|
||||
function(row) {
|
||||
row_id_max = row.rowid;
|
||||
@ -183,20 +183,21 @@ async function getRecentPostIds(db, id, ids, limit) {
|
||||
[].concat([f.rowid, row_id_max], ids_batch, [limit]),
|
||||
function(row) {
|
||||
if (row.id) {
|
||||
recent.push(row.id);
|
||||
recent.push({id: row.id, timestamp: row.timestamp});
|
||||
}
|
||||
if (row.rowid) {
|
||||
f.rowid = Math.max(row.rowid, f.rowid);
|
||||
}
|
||||
});
|
||||
}
|
||||
f.recent.sort((x, y) => x.timestamp - y.timestamp);
|
||||
f.recent = [].concat(recent, f.recent).slice(0, limit);
|
||||
f.recent = [].concat(recent, f.recent);
|
||||
f.recent.sort((x, y) => y.timestamp - x.timestamp);
|
||||
f.recent = f.recent.slice(0, limit);
|
||||
var j = JSON.stringify(f);
|
||||
if (o != j) {
|
||||
await db.set(id + ":recent_posts", j);
|
||||
}
|
||||
return f.recent;
|
||||
return f.recent.map(x => x.id);
|
||||
}
|
||||
|
||||
async function getVotes(db, id) {
|
||||
|
Loading…
Reference in New Issue
Block a user