This commit is contained in:
Bill Thiede 2024-12-19 18:38:43 -08:00
parent 5ddb4452ff
commit e7feb73f6f
2 changed files with 9 additions and 1 deletions

View File

@ -263,6 +263,7 @@ pub struct Tag {
struct SearchCursor { struct SearchCursor {
newsreader_offset: i32, newsreader_offset: i32,
notmuch_offset: i32, notmuch_offset: i32,
#[cfg(feature = "tantivy")]
tantivy_offset: i32, tantivy_offset: i32,
} }
@ -328,10 +329,12 @@ impl QueryRoot {
); );
let newsreader_after = after.as_ref().map(|sc| sc.newsreader_offset); let newsreader_after = after.as_ref().map(|sc| sc.newsreader_offset);
let notmuch_after = after.as_ref().map(|sc| sc.notmuch_offset); let notmuch_after = after.as_ref().map(|sc| sc.notmuch_offset);
#[cfg(feature = "tantivy")]
let tantivy_after = after.as_ref().map(|sc| sc.tantivy_offset); let tantivy_after = after.as_ref().map(|sc| sc.tantivy_offset);
let newsreader_before = before.as_ref().map(|sc| sc.newsreader_offset); let newsreader_before = before.as_ref().map(|sc| sc.newsreader_offset);
let notmuch_before = before.as_ref().map(|sc| sc.notmuch_offset); let notmuch_before = before.as_ref().map(|sc| sc.notmuch_offset);
#[cfg(feature = "tantivy")]
let tantivy_before = before.as_ref().map(|sc| sc.tantivy_offset); let tantivy_before = before.as_ref().map(|sc| sc.tantivy_offset);
let first = first.map(|v| v as i32); let first = first.map(|v| v as i32);
let last = last.map(|v| v as i32); let last = last.map(|v| v as i32);
@ -386,6 +389,7 @@ impl QueryRoot {
results.sort_by_key(|item| match item { results.sort_by_key(|item| match item {
ThreadSummaryCursor::Newsreader(_, ts) => -ts.timestamp, ThreadSummaryCursor::Newsreader(_, ts) => -ts.timestamp,
ThreadSummaryCursor::Notmuch(_, ts) => -ts.timestamp, ThreadSummaryCursor::Notmuch(_, ts) => -ts.timestamp,
#[cfg(feature = "tantivy")]
ThreadSummaryCursor::Tantivy(_, ts) => -ts.timestamp, ThreadSummaryCursor::Tantivy(_, ts) => -ts.timestamp,
}); });
@ -410,6 +414,7 @@ impl QueryRoot {
let mut connection = Connection::new(has_previous_page, has_next_page); let mut connection = Connection::new(has_previous_page, has_next_page);
let mut newsreader_offset = 0; let mut newsreader_offset = 0;
let mut notmuch_offset = 0; let mut notmuch_offset = 0;
#[cfg(feature = "tantivy")]
let mut tantivy_offset = 0; let mut tantivy_offset = 0;
connection.edges.extend(results.into_iter().map(|item| { connection.edges.extend(results.into_iter().map(|item| {
@ -423,6 +428,7 @@ impl QueryRoot {
thread_summary = ts; thread_summary = ts;
notmuch_offset = offset; notmuch_offset = offset;
} }
#[cfg(feature = "tantivy")]
ThreadSummaryCursor::Tantivy(offset, ts) => { ThreadSummaryCursor::Tantivy(offset, ts) => {
thread_summary = ts; thread_summary = ts;
tantivy_offset = offset; tantivy_offset = offset;
@ -431,6 +437,7 @@ impl QueryRoot {
let cur = OpaqueCursor(SearchCursor { let cur = OpaqueCursor(SearchCursor {
newsreader_offset, newsreader_offset,
notmuch_offset, notmuch_offset,
#[cfg(feature = "tantivy")]
tantivy_offset, tantivy_offset,
}); });
Edge::new(cur, thread_summary) Edge::new(cur, thread_summary)
@ -473,6 +480,7 @@ impl QueryRoot {
enum ThreadSummaryCursor { enum ThreadSummaryCursor {
Newsreader(i32, ThreadSummary), Newsreader(i32, ThreadSummary),
Notmuch(i32, ThreadSummary), Notmuch(i32, ThreadSummary),
#[cfg(feature = "tantivy")]
Tantivy(i32, ThreadSummary), Tantivy(i32, ThreadSummary),
} }
async fn newsreader_search( async fn newsreader_search(

View File

@ -258,7 +258,7 @@ impl Transformer for SlurpContents {
let Some(selectors) = self.get_selectors(&link) else { let Some(selectors) = self.get_selectors(&link) else {
return Ok(html.to_string()); return Ok(html.to_string());
}; };
let mut cacher = self.cacher.lock().await; let cacher = self.cacher.lock().await;
let body = if let Some(body) = cacher.get(link.as_str()) { let body = if let Some(body) = cacher.get(link.as_str()) {
info!("cache hit for {link}"); info!("cache hit for {link}");
String::from_utf8_lossy(&body).to_string() String::from_utf8_lossy(&body).to_string()