1
//! Inventories of the form preflight.
2

            
3
use crate::db::DBError;
4
use crate::user::User;
5
use 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.
11
360
pub async fn tenants(admin: Uuid) -> Result<Vec<Uuid>, DBError> {
12
360
    let tenants = crate::fleet::inventory(admin).await?;
13
360
    Ok(tenants.into_iter().map(|(id, _)| id).collect())
14
360
}
15

            
16
impl User {
17
    /// The ids of every stored transaction, splits or not.
18
    ///
19
    /// # Errors
20
    /// [`DBError`] on a connection or query error.
21
900
    pub async fn transaction_ids(&self) -> Result<Vec<Uuid>, DBError> {
22
5
        let mut conn = self.get_connection().await?;
23
5
        sqlx::query_file_scalar!("sql/select/transactions/ids.sql")
24
5
            .fetch_all(&mut *conn)
25
5
            .await
26
5
            .map_err(DBError::Sqlx)
27
5
    }
28
}