revise search data for missing fields
All checks were successful
Build Multiarch Container Image / call-reusable-workflow (push) Successful in 28m27s

This commit is contained in:
Sebastian Hugentobler 2024-06-26 14:46:33 +02:00
parent 40db2c37bb
commit 97cf9db9ff
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
4 changed files with 18 additions and 17 deletions

2
Cargo.lock generated
View File

@ -889,7 +889,7 @@ dependencies = [
[[package]]
name = "little-hesinde"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"calibre-db",
"clap",

View File

@ -14,21 +14,22 @@ use crate::data::{book::Book, error::DataStoreError};
/// A lot of joins but only run once at startup.
const SEARCH_INIT_QUERY: &str = "INSERT INTO search.fts(book_id, data)
SELECT b.id as book_id,
b.title || ' ' ||
a.name || ' ' ||
c.text || ' ' ||
GROUP_CONCAT(DISTINCT t.name) || ' ' ||
GROUP_CONCAT(DISTINCT i.val) || ' ' ||
GROUP_CONCAT(DISTINCT s.name) as data
COALESCE(b.title, '') || ' ' ||
COALESCE(a.name, '') || ' ' ||
COALESCE(c.text, '') || ' ' ||
COALESCE(GROUP_CONCAT(DISTINCT t.name), '') || ' ' ||
COALESCE(GROUP_CONCAT(DISTINCT i.val), '') || ' ' ||
COALESCE(GROUP_CONCAT(DISTINCT s.name), '') as data
FROM main.books as b
JOIN main.books_authors_link AS b2a ON b.id = b2a.book
JOIN main.authors AS a ON b2a.author = a.id
JOIN main.comments AS c ON c.book = b.id
JOIN main.books_tags_link AS b2t ON b.id = b2t.book
JOIN main.tags AS t ON b2t.tag = t.id
JOIN main.identifiers AS i ON i.book = b.id
JOIN main.books_series_link AS b2s ON b.id = b2s.book
JOIN main.series AS s ON b2s.series = s.id";
LEFT JOIN main.books_authors_link AS b2a ON b.id = b2a.book
LEFT JOIN main.authors AS a ON b2a.author = a.id
LEFT JOIN main.comments AS c ON c.book = b.id
LEFT JOIN main.books_tags_link AS b2t ON b.id = b2t.book
LEFT JOIN main.tags AS t ON b2t.tag = t.id
LEFT JOIN main.identifiers AS i ON i.book = b.id
LEFT JOIN main.books_series_link AS b2s ON b.id = b2s.book
LEFT JOIN main.series AS s ON b2s.series = s.id
GROUP BY b.id";
/// Attach the fts in-memory database to the read-only calibre database.
pub(crate) fn attach(pool: &Pool<SqliteConnectionManager>) -> Result<(), DataStoreError> {

View File

@ -1,6 +1,6 @@
[package]
name = "little-hesinde"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = { workspace = true }
authors = { workspace = true }

View File

@ -76,7 +76,7 @@ pub mod opds {
pub mod templates;
pub const APP_NAME: &str = "little-hesinde";
pub const VERSION: &str = "0.2.0";
pub const VERSION: &str = "0.2.1";
/// Internal marker data in lieu of a proper `Accept` header.
#[derive(Debug, Clone, Copy)]