Display global statistics
This commit is contained in:
@@ -112,6 +112,13 @@ pub async fn delete_file_if_unused(id: FileID) -> anyhow::Result<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all the files of a user
|
||||
pub async fn get_all_files_user(user_id: UserID) -> anyhow::Result<Vec<File>> {
|
||||
Ok(files::table
|
||||
.filter(files::dsl::user_id.eq(user_id.0))
|
||||
.load(&mut db()?)?)
|
||||
}
|
||||
|
||||
/// Get the entire list of file
|
||||
pub async fn get_entire_list() -> anyhow::Result<Vec<File>> {
|
||||
Ok(files::table.get_results(&mut db()?)?)
|
||||
|
@@ -162,6 +162,17 @@ pub async fn get_balances(user_id: UserID) -> anyhow::Result<HashMap<AccountID,
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Get all the movements of the user
|
||||
pub async fn get_all_movements_user(user_id: UserID) -> anyhow::Result<Vec<Movement>> {
|
||||
let movements = sql_query(format!(
|
||||
"select m.* from movements m join accounts a on a.id = m.account_id where a.user_id = {}",
|
||||
user_id.0
|
||||
))
|
||||
.load::<Movement>(&mut db()?)?;
|
||||
|
||||
Ok(movements)
|
||||
}
|
||||
|
||||
/// Delete a movement
|
||||
pub async fn delete(id: MovementID) -> anyhow::Result<()> {
|
||||
diesel::delete(movements::dsl::movements.filter(movements::dsl::id.eq(id.0)))
|
||||
|
Reference in New Issue
Block a user