summaryrefslogtreecommitdiff
path: root/backend/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'backend/app/src')
-rw-r--r--backend/app/src/main.rs2
-rw-r--r--backend/app/src/routes/account.rs15
-rw-r--r--backend/app/src/routes/balance.rs7
-rw-r--r--backend/app/src/routes/budget.rs2
4 files changed, 6 insertions, 20 deletions
diff --git a/backend/app/src/main.rs b/backend/app/src/main.rs
index 152f958..dca6096 100644
--- a/backend/app/src/main.rs
+++ b/backend/app/src/main.rs
@@ -8,9 +8,7 @@ use rocket::{launch, routes, Build, Rocket};
use crate::databases::UserDataDb;
pub mod databases;
-pub mod queries;
pub mod routes;
-pub mod utils;
fn run_database_migrations(connection: &mut SqliteConnection) {
connection
diff --git a/backend/app/src/routes/account.rs b/backend/app/src/routes/account.rs
index e4eb153..96f1f38 100644
--- a/backend/app/src/routes/account.rs
+++ b/backend/app/src/routes/account.rs
@@ -1,8 +1,7 @@
use budgeting_app_core::{
models::account::Account,
- queries::accounts::{get_all_accounts as get_all_accounts_query, insert_account},
+ queries::accounts::{get_all_accounts as get_all_accounts_query, insert_accounts},
};
-use diesel::result::DatabaseErrorKind;
use rocket::http::Status;
use rocket::serde::json::Json;
use rocket::{get, post, Responder};
@@ -39,21 +38,13 @@ pub async fn create_account(
let accounts_vec = vec![account.clone()];
let num_rows_inserted = user_data_db
- .run(move |connection| insert_account(&accounts_vec, connection))
+ .run(move |connection| insert_accounts(&accounts_vec, connection))
.await;
match num_rows_inserted {
Ok(_) => CreateAccountResponder::Created(Json(account)),
- Err(err) => match err {
- diesel::result::Error::DatabaseError(DatabaseErrorKind::UniqueViolation, info) => {
- let column = info.column_name().unwrap_or("account");
- CreateAccountResponder::BadRequest(format!(
- "Error creating account: {column} was not unique."
- ))
- }
- _ => CreateAccountResponder::InternalServerError(format!(
+ Err(err) => CreateAccountResponder::InternalServerError(format!(
"Error creating account: {err}"
)),
- },
}
}
diff --git a/backend/app/src/routes/balance.rs b/backend/app/src/routes/balance.rs
index 2dcae7b..21adb3b 100644
--- a/backend/app/src/routes/balance.rs
+++ b/backend/app/src/routes/balance.rs
@@ -1,13 +1,10 @@
use budgeting_app_core::{
models::category_balance::CategoryBalance,
- queries::category_balances::get_all_category_balances as get_all_category_balances_query,
+ queries::categories::get_all_category_balances as get_all_category_balances_query,
};
use rocket::{get, http::Status, serde::json::Json};
-use crate::{
- databases::UserDataDb,
-};
-
+use crate::databases::UserDataDb;
#[get("/balance/category")]
pub async fn get_all_category_balances(
user_data_db: UserDataDb,
diff --git a/backend/app/src/routes/budget.rs b/backend/app/src/routes/budget.rs
index 746635b..dc0802a 100644
--- a/backend/app/src/routes/budget.rs
+++ b/backend/app/src/routes/budget.rs
@@ -1,6 +1,6 @@
use budgeting_app_core::{
models::category_budget::CategoryBudget,
- queries::category_budgets::get_most_recent_category_budget_per_category_id as get_most_recent_category_budget_per_category_id_query,
+ queries::categories::get_most_recent_category_budget_per_category_id as get_most_recent_category_budget_per_category_id_query,
};
use rocket::get;
use rocket::http::Status;