Try showing the last day's worth of posts.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3868 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
804359d12e
commit
0d1b231344
@ -1 +1 @@
|
|||||||
{"type":"tildefriends-app","files":{"app.js":"&nbY2UrHp+GcW1FrromCZRyJNg7in7InypXSaFNipTrs=.sha256","index.html":"&oAZVhNbqs9mLhgZj6VLgRvmCYuiGjp9D+ZH3vFV/ViM=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&BwircO1usZwNmgxReG3COtztqg6bVYnVenTKsLhOeLI=.sha256","tf-message.js":"&TcKxV+QGU2LQ+yLtZbD1xdWfDSAPLRj47fBaydho3ts=.sha256","tf.js":"&ih5SgLokhC5wnL7VNnFhSD/t2mqs5gTFzUUFWBlMp3k=.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":"&g17mCj0bfk0tw0sYk2VMU67Bt8Hdznjl44E01TxQF5Y=.sha256"}}
|
{"type":"tildefriends-app","files":{"app.js":"&j8ONkf2VtLJ2+MCvwTd0hCOl074G1XFAHcJuZCxmN0k=.sha256","index.html":"&oAZVhNbqs9mLhgZj6VLgRvmCYuiGjp9D+ZH3vFV/ViM=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&BwircO1usZwNmgxReG3COtztqg6bVYnVenTKsLhOeLI=.sha256","tf-message.js":"&TcKxV+QGU2LQ+yLtZbD1xdWfDSAPLRj47fBaydho3ts=.sha256","tf.js":"&ih5SgLokhC5wnL7VNnFhSD/t2mqs5gTFzUUFWBlMp3k=.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":"&g17mCj0bfk0tw0sYk2VMU67Bt8Hdznjl44E01TxQF5Y=.sha256"}}
|
@ -259,6 +259,42 @@ async function getRecentPostIds(db, id, ids, limit) {
|
|||||||
return f.recent.map(x => x.id);
|
return f.recent.map(x => x.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getRecentPostIds2(db, id, ids, start_time) {
|
||||||
|
const k_batch_max = 32;
|
||||||
|
var row_id_max = 0;
|
||||||
|
await ssb.sqlStream(
|
||||||
|
"SELECT MAX(rowid) as rowid FROM messages",
|
||||||
|
[],
|
||||||
|
function(row) {
|
||||||
|
row_id_max = row.rowid;
|
||||||
|
});
|
||||||
|
var posts_by_author = {};
|
||||||
|
for (var i = 0; i < ids.length; i += k_batch_max) {
|
||||||
|
var ids_batch = ids.slice(i, Math.min(i + k_batch_max, ids.length));
|
||||||
|
await ssb.sqlStream(
|
||||||
|
"SELECT "+
|
||||||
|
" author, "+
|
||||||
|
" id "+
|
||||||
|
"FROM messages "+
|
||||||
|
"WHERE "+
|
||||||
|
" author IN (" + ids_batch.map(x => '?').join(", ") + ") AND "+
|
||||||
|
" timestamp > ? AND "+
|
||||||
|
" rowid <= ? AND "+
|
||||||
|
" json_extract(content, '$.type') = 'post' "+
|
||||||
|
"ORDER BY timestamp",
|
||||||
|
[].concat(ids_batch, [start_time, row_id_max]),
|
||||||
|
function(row) {
|
||||||
|
if (row.id) {
|
||||||
|
if (!posts_by_author[row.author]) {
|
||||||
|
posts_by_author[row.author] = [];
|
||||||
|
}
|
||||||
|
posts_by_author[row.author].push(row.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Object.values(posts_by_author).map(x => x[0]);
|
||||||
|
}
|
||||||
|
|
||||||
async function getRelatedPostIds(db, message, ids, limit) {
|
async function getRelatedPostIds(db, message, ids, limit) {
|
||||||
const k_batch_max = 16;
|
const k_batch_max = 16;
|
||||||
var recent = [];
|
var recent = [];
|
||||||
@ -430,7 +466,7 @@ async function refresh(selected) {
|
|||||||
m = m.length ? m[0] : {id: selected[0]};
|
m = m.length ? m[0] : {id: selected[0]};
|
||||||
ids = await getRelatedPostIds(db, m, all_followed, k_posts_max);
|
ids = await getRelatedPostIds(db, m, all_followed, k_posts_max);
|
||||||
} else {
|
} else {
|
||||||
ids = await getRecentPostIds(db, whoami, g_selected, k_posts_max);
|
ids = await getRecentPostIds2(db, whoami, g_selected, (new Date()).valueOf() - (24 * 60 * 60 * 1000));
|
||||||
}
|
}
|
||||||
timing.push({name: 'get_post_ids', time: new Date()});
|
timing.push({name: 'get_post_ids', time: new Date()});
|
||||||
var posts = await getPosts(db, ids);
|
var posts = await getPosts(db, ids);
|
||||||
|
Loading…
Reference in New Issue
Block a user