From 7ba1e6980f7b121aca9c40040a61e1b992c142d7 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 13 Jan 2022 00:16:27 +0000 Subject: [PATCH] Some UI tweaks and some sqlite performance things. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3755 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 4 ++-- apps/cory/index/tf-message.js | 2 +- src/ssb.db.c | 2 ++ src/ssb.export.c | 2 +- src/ssb.import.c | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index 37d54edb..31e1b869 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&qrR7s0k3vd/aGg03JurUTRMzWyPIEMwGiKAEYNpHpT8=.sha256","index.html":"&/CE4CuVKI56h5tfAHF0kzCXbLfhVjWzsM8aZAB9HpEM=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&A/R6o9GsaDTEyoAIS8EE1ATCfugBlhdS+jdMz7vsfsM=.sha256","tf.js":"&gJUMwBsssB+Suy/NTUjcB3JeloFLvV18i6egqvThaVY=.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"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&chjdt5GtpAo/mI5TNU4n5erT2easdEgJqVrJHz6HtlA=.sha256","index.html":"&/CE4CuVKI56h5tfAHF0kzCXbLfhVjWzsM8aZAB9HpEM=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&gBMlL/D2sGuvFQR46qXM1ERLA+baZDp9h/4jOD42k7w=.sha256","tf.js":"&gJUMwBsssB+Suy/NTUjcB3JeloFLvV18i6egqvThaVY=.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"}} \ No newline at end of file diff --git a/apps/cory/index/app.js b/apps/cory/index/app.js index 48eb5172..6fb92ec1 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -237,9 +237,9 @@ async function getRelatedPostIds(db, message, ids, limit) { " rowid <= ? AND "+ " author IN (" + ids_batch.map(x => '?').join(", ") + ") AND "+ " json_extract(content, '$.type') = 'post' AND "+ - " json_extract(content, '$.root') = ? "+ + " (id = ? OR json_extract(content, '$.root') = ?) "+ "ORDER BY timestamp DESC LIMIT ?", - [].concat([message.timestamp, row_id_max], ids_batch, [id, limit]), + [].concat([message.timestamp, row_id_max], ids_batch, [message.id, id, limit]), function(row) { if (row.id) { recent.push({id: row.id, timestamp: row.timestamp}); diff --git a/apps/cory/index/tf-message.js b/apps/cory/index/tf-message.js index 03db16c6..a8e9a4d9 100644 --- a/apps/cory/index/tf-message.js +++ b/apps/cory/index/tf-message.js @@ -53,7 +53,7 @@ Vue.component('tf-message', { template: `

- + percent diff --git a/src/ssb.db.c b/src/ssb.db.c index 2ca59603..8ba52fdf 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -12,6 +12,8 @@ void tf_ssb_db_init(tf_ssb_t* ssb) { sqlite3* db = tf_ssb_get_db(ssb); + sqlite3_exec(db, "PRAGMA journal_mode = WAL", NULL, NULL, NULL); + sqlite3_exec(db, "PRAGMA synchronous = NORMAL", NULL, NULL, NULL); sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS messages (" " author TEXT," diff --git a/src/ssb.export.c b/src/ssb.export.c index 00305209..b5ecd82e 100644 --- a/src/ssb.export.c +++ b/src/ssb.export.c @@ -41,7 +41,7 @@ void tf_ssb_export(tf_ssb_t* ssb, const char* key) } char app_blob_id[64] = { 0 }; - + sqlite3_busy_timeout(tf_ssb_get_db(ssb), 10000); sqlite3_stmt* statement; if (sqlite3_prepare(tf_ssb_get_db(ssb), "SELECT value FROM properties WHERE id = $1 AND key = 'path:' || $2", -1, &statement, NULL) == SQLITE_OK) { diff --git a/src/ssb.import.c b/src/ssb.import.c index 5e29a060..8f6c5183 100644 --- a/src/ssb.import.c +++ b/src/ssb.import.c @@ -125,6 +125,7 @@ void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path) .work_left = 1, }; import.req.data = &import; + sqlite3_busy_timeout(tf_ssb_get_db(ssb), 10000); int r = uv_fs_scandir(tf_ssb_get_loop(ssb), &import.req, path, 0, _tf_ssb_import_scandir); if (r) {