From a373647c2da1f1c5e8481c3c2ff2638dda2fdd1e Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 13 Jul 2024 15:12:49 +0200 Subject: [PATCH] Remove duplication in function names --- src/frontend/item.rs | 28 ++++++++++++++-------------- src/frontend/item_class.rs | 31 ++++++++++++++----------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/frontend/item.rs b/src/frontend/item.rs index 034631b..a0ac9c0 100644 --- a/src/frontend/item.rs +++ b/src/frontend/item.rs @@ -16,17 +16,17 @@ use crate::manage; use crate::models::*; pub fn config(cfg: &mut web::ServiceConfig) { - cfg.service(show_item) - .service(list_items) - .service(add_item) - .service(add_item_post) - .service(edit_item) - .service(edit_item_post) - .service(delete_item); + cfg.service(show) + .service(list) + .service(add_form) + .service(add_post) + .service(edit_form) + .service(edit) + .service(delete); } #[get("/item/{id}")] -async fn show_item( +async fn show( pool: web::Data, path: web::Path, user: Identity, @@ -123,7 +123,7 @@ async fn show_item( } #[get("/items")] -async fn list_items(pool: web::Data, user: Identity) -> actix_web::Result { +async fn list(pool: web::Data, user: Identity) -> actix_web::Result { let item_list = manage::item::get_all(&pool) .await .map_err(error::ErrorInternalServerError)?; @@ -199,7 +199,7 @@ async fn list_items(pool: web::Data, user: Identity) -> actix_web::Resul } #[get("/items/add")] -async fn add_item( +async fn add_form( pool: web::Data, form: web::Query, user: Identity, @@ -255,7 +255,7 @@ async fn add_item( } #[post("/items/add")] -async fn add_item_post( +async fn add_post( data: web::Form, pool: web::Data, _user: Identity, @@ -267,7 +267,7 @@ async fn add_item_post( } #[get("/item/{id}/edit")] -async fn edit_item( +async fn edit_form( pool: web::Data, path: web::Path, user: Identity, @@ -348,7 +348,7 @@ async fn edit_item( } #[post("/item/{id}/edit")] -async fn edit_item_post( +async fn edit( pool: web::Data, path: web::Path, data: web::Form, @@ -364,7 +364,7 @@ async fn edit_item_post( } #[post("/item/{id}/delete")] -async fn delete_item( +async fn delete( pool: web::Data, path: web::Path, _user: Identity, diff --git a/src/frontend/item_class.rs b/src/frontend/item_class.rs index 79e1edf..ecfacd1 100644 --- a/src/frontend/item_class.rs +++ b/src/frontend/item_class.rs @@ -14,17 +14,17 @@ use crate::manage; use crate::models::*; pub fn config(cfg: &mut web::ServiceConfig) { - cfg.service(show_item_class) - .service(list_item_classes) - .service(add_item_class) - .service(add_item_class_post) - .service(edit_item_class) - .service(edit_item_class_post) - .service(delete_item_class); + cfg.service(show) + .service(list) + .service(add_form) + .service(add) + .service(edit_form) + .service(edit) + .service(delete); } #[get("/item-class/{id}")] -async fn show_item_class( +async fn show( pool: web::Data, path: web::Path, user: Identity, @@ -123,10 +123,7 @@ async fn show_item_class( } #[get("/item-classes")] -async fn list_item_classes( - pool: web::Data, - user: Identity, -) -> actix_web::Result { +async fn list(pool: web::Data, user: Identity) -> actix_web::Result { let item_classes_ids = sqlx::query_scalar!("SELECT id FROM item_classes ORDER BY created_at") .fetch_all(pool.as_ref()) .await @@ -182,7 +179,7 @@ async fn list_item_classes( } #[get("/item-classes/add")] -async fn add_item_class( +async fn add_form( pool: web::Data, form: web::Query, user: Identity, @@ -227,7 +224,7 @@ async fn add_item_class( } #[post("/item-classes/add")] -async fn add_item_class_post( +async fn add( data: web::Form, pool: web::Data, _user: Identity, @@ -239,7 +236,7 @@ async fn add_item_class_post( } #[get("/item-class/{id}/edit")] -async fn edit_item_class( +async fn edit_form( pool: web::Data, path: web::Path, user: Identity, @@ -302,7 +299,7 @@ async fn edit_item_class( } #[post("/item-class/{id}/edit")] -async fn edit_item_class_post( +async fn edit( pool: web::Data, path: web::Path, data: web::Form, @@ -318,7 +315,7 @@ async fn edit_item_class_post( } #[post("/item-class/{id}/delete")] -async fn delete_item_class( +async fn delete( pool: web::Data, path: web::Path, _user: Identity,