server: instrument newsreader impl
This commit is contained in:
parent
94c03a9c7c
commit
0222985f4d
@ -7,6 +7,7 @@ use scraper::Selector;
|
||||
use shared::compute_color;
|
||||
use sqlx::postgres::PgPool;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::instrument;
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
@ -52,6 +53,7 @@ fn site_from_tags(tags: &[String]) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
#[instrument(name = "newsreader::count", skip_all, fields(query=%query))]
|
||||
pub async fn count(pool: &PgPool, query: &Query) -> Result<usize, ServerError> {
|
||||
if !is_newsreader_query(query) {
|
||||
return Ok(0);
|
||||
@ -75,6 +77,7 @@ pub async fn count(pool: &PgPool, query: &Query) -> Result<usize, ServerError> {
|
||||
Ok(row.count.unwrap_or(0).try_into().unwrap_or(0))
|
||||
}
|
||||
|
||||
#[instrument(name = "newsreader::search", skip_all, fields(query=%query))]
|
||||
pub async fn search(
|
||||
pool: &PgPool,
|
||||
after: Option<i32>,
|
||||
@ -141,6 +144,7 @@ pub async fn search(
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
#[instrument(name = "newsreader::tags", skip_all, fields(needs_unread=%_needs_unread))]
|
||||
pub async fn tags(pool: &PgPool, _needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
||||
// TODO: optimize query by using needs_unread
|
||||
let tags = sqlx::query_file!("sql/tags.sql").fetch_all(pool).await?;
|
||||
@ -164,6 +168,7 @@ pub async fn tags(pool: &PgPool, _needs_unread: bool) -> Result<Vec<Tag>, Server
|
||||
Ok(tags)
|
||||
}
|
||||
|
||||
#[instrument(name = "newsreader::thread", skip_all, fields(thread_id=%thread_id))]
|
||||
pub async fn thread(
|
||||
config: &Config,
|
||||
pool: &PgPool,
|
||||
@ -280,6 +285,7 @@ pub async fn thread(
|
||||
timestamp,
|
||||
}))
|
||||
}
|
||||
#[instrument(name = "newsreader::set_read_status", skip_all, fields(query=%query,unread=%unread))]
|
||||
pub async fn set_read_status<'ctx>(
|
||||
pool: &PgPool,
|
||||
query: &Query,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user