Compare commits
No commits in common. "80454cbc7e62b74040747313fd2f32afead69e58" and "d9d58afed9ee527c5947c5ac968c07d1682445d3" have entirely different histories.
80454cbc7e
...
d9d58afed9
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -2910,7 +2910,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox"
|
name = "letterbox"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-info",
|
"build-info",
|
||||||
"build-info-build",
|
"build-info-build",
|
||||||
@ -2936,7 +2936,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-server"
|
name = "letterbox-server"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ammonia",
|
"ammonia",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@ -2949,7 +2949,6 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"css-inline",
|
"css-inline",
|
||||||
"futures 0.3.31",
|
|
||||||
"html-escape",
|
"html-escape",
|
||||||
"linkify",
|
"linkify",
|
||||||
"log",
|
"log",
|
||||||
@ -3457,7 +3456,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "notmuch"
|
name = "notmuch"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.10.5",
|
"itertools 0.10.5",
|
||||||
"log",
|
"log",
|
||||||
@ -4252,7 +4251,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "procmail2notmuch"
|
name = "procmail2notmuch"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
]
|
]
|
||||||
@ -5331,7 +5330,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shared"
|
name = "shared"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-info",
|
"build-info",
|
||||||
"notmuch",
|
"notmuch",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "notmuch"
|
name = "notmuch"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "procmail2notmuch"
|
name = "procmail2notmuch"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT\n p.id,\n link,\n clean_summary\nFROM\n-- Remoe tablesample when db sufficiently indexed\n post AS p TABLESAMPLE SYSTEM (.1)\nINNER JOIN feed AS f ON p.site = f.slug -- necessary to weed out nzb posts\nWHERE search_summary IS NULL;\n",
|
"query": "SELECT\n p.id,\n link,\n clean_summary\nFROM\n post AS p TABLESAMPLE SYSTEM (.1)\nINNER JOIN feed AS f ON p.site = f.slug -- necessary to weed out nzb posts\nWHERE search_summary IS NULL;\n",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@ -28,5 +28,5 @@
|
|||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "26e150d5d294f2eb264bbae21766295c4e4e5fe1e076dd7d6bc168e5fb49dc84"
|
"hash": "078322a8e99faa6b91e3890501f6763e8787b181d5fd070267180b0d5180ca36"
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "letterbox-server"
|
name = "letterbox-server"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "letterbox-server"
|
default-run = "letterbox-server"
|
||||||
|
|
||||||
@ -17,7 +17,6 @@ cacher = { version = "0.1.0", registry = "xinu" }
|
|||||||
chrono = "0.4.39"
|
chrono = "0.4.39"
|
||||||
clap = { version = "4.5.23", features = ["derive"] }
|
clap = { version = "4.5.23", features = ["derive"] }
|
||||||
css-inline = "0.13.0"
|
css-inline = "0.13.0"
|
||||||
futures = "0.3.31"
|
|
||||||
html-escape = "0.2.13"
|
html-escape = "0.2.13"
|
||||||
linkify = "0.10.0"
|
linkify = "0.10.0"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
|
|||||||
@ -3,7 +3,6 @@ SELECT
|
|||||||
link,
|
link,
|
||||||
clean_summary
|
clean_summary
|
||||||
FROM
|
FROM
|
||||||
-- Remoe tablesample when db sufficiently indexed
|
|
||||||
post AS p TABLESAMPLE SYSTEM (.1)
|
post AS p TABLESAMPLE SYSTEM (.1)
|
||||||
INNER JOIN feed AS f ON p.site = f.slug -- necessary to weed out nzb posts
|
INNER JOIN feed AS f ON p.site = f.slug -- necessary to weed out nzb posts
|
||||||
WHERE search_summary IS NULL;
|
WHERE search_summary IS NULL;
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use cacher::FilesystemCacher;
|
use cacher::FilesystemCacher;
|
||||||
use futures::{stream::FuturesUnordered, StreamExt};
|
|
||||||
use log::info;
|
use log::info;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use scraper::Selector;
|
use scraper::Selector;
|
||||||
@ -255,25 +254,23 @@ pub async fn set_read_status<'ctx>(
|
|||||||
}
|
}
|
||||||
#[instrument(name = "newsreader::refresh", skip_all)]
|
#[instrument(name = "newsreader::refresh", skip_all)]
|
||||||
pub async fn refresh<'ctx>(pool: &PgPool, cacher: &FilesystemCacher) -> Result<bool, ServerError> {
|
pub async fn refresh<'ctx>(pool: &PgPool, cacher: &FilesystemCacher) -> Result<bool, ServerError> {
|
||||||
async fn update_search_summary(
|
let body_transformers: Vec<Box<dyn Transformer>> = vec![
|
||||||
pool: &PgPool,
|
Box::new(SlurpContents {
|
||||||
cacher: &FilesystemCacher,
|
cacher,
|
||||||
link: Url,
|
inline_css: true,
|
||||||
body: String,
|
site_selectors: slurp_contents_selectors(),
|
||||||
id: i32,
|
}),
|
||||||
) -> Result<(), ServerError> {
|
Box::new(StripHtml),
|
||||||
let body_transformers: Vec<Box<dyn Transformer>> = vec![
|
];
|
||||||
Box::new(SlurpContents {
|
|
||||||
cacher,
|
|
||||||
inline_css: true,
|
|
||||||
site_selectors: slurp_contents_selectors(),
|
|
||||||
}),
|
|
||||||
Box::new(StripHtml),
|
|
||||||
];
|
|
||||||
|
|
||||||
|
let rows = sqlx::query_file!("sql/need-search-summary.sql",)
|
||||||
|
.fetch_all(pool)
|
||||||
|
.await?;
|
||||||
|
for r in rows {
|
||||||
|
let link = Url::parse(&r.link)?;
|
||||||
info!("adding {link} to search index");
|
info!("adding {link} to search index");
|
||||||
let mut body = body;
|
|
||||||
let link = Some(link);
|
let link = Some(link);
|
||||||
|
let mut body = r.clean_summary.unwrap_or("NO SUMMARY".to_string());
|
||||||
for t in body_transformers.iter() {
|
for t in body_transformers.iter() {
|
||||||
if t.should_run(&link, &body) {
|
if t.should_run(&link, &body) {
|
||||||
body = t.transform(&link, &body).await?;
|
body = t.transform(&link, &body).await?;
|
||||||
@ -282,35 +279,10 @@ pub async fn refresh<'ctx>(pool: &PgPool, cacher: &FilesystemCacher) -> Result<b
|
|||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"UPDATE post SET search_summary = $1 WHERE id = $2",
|
"UPDATE post SET search_summary = $1 WHERE id = $2",
|
||||||
body,
|
body,
|
||||||
id
|
r.id
|
||||||
)
|
)
|
||||||
.execute(pool)
|
.execute(pool)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut unordered: FuturesUnordered<_> = sqlx::query_file!("sql/need-search-summary.sql",)
|
|
||||||
.fetch_all(pool)
|
|
||||||
.await?
|
|
||||||
.into_iter()
|
|
||||||
.map(|r| {
|
|
||||||
let link = Url::parse(&r.link).expect("failed to parse link");
|
|
||||||
let body = r.clean_summary.unwrap_or("NO SUMMARY".to_string());
|
|
||||||
let id = r.id;
|
|
||||||
update_search_summary(pool, cacher, link, body, id)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
while let Some(res) = unordered.next().await {
|
|
||||||
//let res = res;
|
|
||||||
match res {
|
|
||||||
Ok(()) => {}
|
|
||||||
Err(err) => {
|
|
||||||
info!("failed refresh {err:?}");
|
|
||||||
// TODO:
|
|
||||||
//fd.error = Some(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "shared"
|
name = "shared"
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
version = "0.0.122"
|
version = "0.0.121"
|
||||||
name = "letterbox"
|
name = "letterbox"
|
||||||
repository = "https://github.com/seed-rs/seed-quickstart"
|
repository = "https://github.com/seed-rs/seed-quickstart"
|
||||||
authors = ["Bill Thiede <git@xinu.tv>"]
|
authors = ["Bill Thiede <git@xinu.tv>"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user