mirror of
https://git.dirksys.ovh/dirk/bankserver.git
synced 2025-12-20 19:19:21 +01:00
add instrumentation to chat functions
This commit is contained in:
parent
0d5a182e4f
commit
6e9f12c97b
@ -2,6 +2,7 @@ use chrono::{DateTime, Utc};
|
|||||||
use deadpool_postgres::GenericClient;
|
use deadpool_postgres::GenericClient;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use tokio_postgres::Row;
|
use tokio_postgres::Row;
|
||||||
|
use tracing::instrument;
|
||||||
use uuid::{NoContext, Timestamp, Uuid};
|
use uuid::{NoContext, Timestamp, Uuid};
|
||||||
|
|
||||||
use crate::api::{Pagination, PaginationType, RequestPagination};
|
use crate::api::{Pagination, PaginationType, RequestPagination};
|
||||||
@ -74,6 +75,7 @@ impl From<Row> for ChatMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Chat {
|
impl Chat {
|
||||||
|
#[instrument(skip(client))]
|
||||||
pub async fn exists(
|
pub async fn exists(
|
||||||
client: &impl GenericClient,
|
client: &impl GenericClient,
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
@ -85,6 +87,7 @@ impl Chat {
|
|||||||
Ok(result.get(0))
|
Ok(result.get(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client))]
|
||||||
pub async fn exists_and_has_access(
|
pub async fn exists_and_has_access(
|
||||||
client: &impl GenericClient,
|
client: &impl GenericClient,
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
@ -99,6 +102,7 @@ impl Chat {
|
|||||||
Ok(result.get::<_, bool>(0).then_some(result.get(1)))
|
Ok(result.get::<_, bool>(0).then_some(result.get(1)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client))]
|
||||||
pub async fn get_by_id(
|
pub async fn get_by_id(
|
||||||
client: &impl GenericClient,
|
client: &impl GenericClient,
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
@ -117,6 +121,7 @@ impl Chat {
|
|||||||
Ok(result.map(|v| v.get(0)))
|
Ok(result.map(|v| v.get(0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client))]
|
||||||
pub async fn start(
|
pub async fn start(
|
||||||
client: &mut impl GenericClient,
|
client: &mut impl GenericClient,
|
||||||
initiator: Uuid,
|
initiator: Uuid,
|
||||||
@ -147,6 +152,7 @@ impl Chat {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client))]
|
||||||
pub async fn list_for_user(
|
pub async fn list_for_user(
|
||||||
client: &impl GenericClient,
|
client: &impl GenericClient,
|
||||||
user: Uuid,
|
user: Uuid,
|
||||||
@ -164,6 +170,7 @@ impl Chat {
|
|||||||
Ok(Pagination::new(result, total, pagination))
|
Ok(Pagination::new(result, total, pagination))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client))]
|
||||||
pub async fn messages(
|
pub async fn messages(
|
||||||
client: &impl GenericClient,
|
client: &impl GenericClient,
|
||||||
chat: Uuid,
|
chat: Uuid,
|
||||||
@ -185,6 +192,7 @@ impl Chat {
|
|||||||
Ok(Pagination::new(result, total, pagination))
|
Ok(Pagination::new(result, total, pagination))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(skip(client, text, extra))]
|
||||||
pub async fn send(
|
pub async fn send(
|
||||||
client: &mut impl GenericClient,
|
client: &mut impl GenericClient,
|
||||||
chat: Uuid,
|
chat: Uuid,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user