Implement newsreader counting

This commit is contained in:
2024-07-21 15:13:09 -07:00
parent abaaddae3a
commit 9746c9912b
5 changed files with 67 additions and 18 deletions

View File

@@ -209,7 +209,14 @@ pub struct QueryRoot;
impl QueryRoot {
async fn count<'ctx>(&self, ctx: &Context<'ctx>, query: String) -> Result<usize, Error> {
let nm = ctx.data_unchecked::<Notmuch>();
Ok(nm.count(&query)?)
let pool = ctx.data_unchecked::<PgPool>();
// TODO: make this search both copra and merge results
if newsreader::is_newsreader_search(&query) {
Ok(newsreader::count(pool, &query).await?)
} else {
Ok(nm::count(nm, &query).await?)
}
}
async fn search<'ctx>(