Skip to main content

server/
preflight.rs

1//! Inventories of the form preflight.
2
3use crate::db::DBError;
4use crate::user::User;
5use sqlx::types::Uuid;
6
7/// The ids of the tenants of the directory, except the admin.
8///
9/// # Errors
10/// [`DBError`] when the directory cannot be read.
11pub async fn tenants(admin: Uuid) -> Result<Vec<Uuid>, DBError> {
12    let tenants = crate::fleet::inventory(admin).await?;
13    Ok(tenants.into_iter().map(|(id, _)| id).collect())
14}
15
16impl User {
17    /// The ids of every stored transaction, splits or not.
18    ///
19    /// # Errors
20    /// [`DBError`] on a connection or query error.
21    pub async fn transaction_ids(&self) -> Result<Vec<Uuid>, DBError> {
22        let mut conn = self.get_connection().await?;
23        sqlx::query_file_scalar!("sql/select/transactions/ids.sql")
24            .fetch_all(&mut *conn)
25            .await
26            .map_err(DBError::Sqlx)
27    }
28}