summaryrefslogtreecommitdiff
path: root/rust/app/src/routes/budget.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2024-11-17 09:23:28 +0000
committerJoe Carstairs <me@joeac.net>2024-11-17 09:23:28 +0000
commit1ae19eb3315c40e3f9062592c27fa76c11cf626c (patch)
tree09d9ce380795971f4b50e1d4b0ca3c57c9e1db1a /rust/app/src/routes/budget.rs
parent1a494937021561595d0fb29e26fb707aef9e55de (diff)
Renames workspace folder
Diffstat (limited to 'rust/app/src/routes/budget.rs')
-rw-r--r--rust/app/src/routes/budget.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/rust/app/src/routes/budget.rs b/rust/app/src/routes/budget.rs
new file mode 100644
index 0000000..dc0802a
--- /dev/null
+++ b/rust/app/src/routes/budget.rs
@@ -0,0 +1,20 @@
+use budgeting_app_core::{
+ models::category_budget::CategoryBudget,
+ 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;
+use rocket::serde::json::Json;
+
+use crate::databases::UserDataDb;
+
+#[get("/budget/category?current")]
+pub async fn get_current_category_budget_per_category(
+ user_data_db: UserDataDb,
+) -> Result<Json<Vec<CategoryBudget>>, Status> {
+ user_data_db
+ .run(get_most_recent_category_budget_per_category_id_query)
+ .await
+ .map(Json)
+ .map_err(|_| Status { code: 500 })
+}