Remove duplication in function names

This commit is contained in:
Simon Bruder 2024-07-13 15:12:49 +02:00
parent 7100c29dd3
commit 21cd61ea1d
Signed by: simon
GPG key ID: 347FF8699CDA0776
2 changed files with 28 additions and 31 deletions

View file

@ -16,17 +16,17 @@ use crate::manage;
use crate::models::*; use crate::models::*;
pub fn config(cfg: &mut web::ServiceConfig) { pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(show_item) cfg.service(show)
.service(list_items) .service(list)
.service(add_item) .service(add_form)
.service(add_item_post) .service(add_post)
.service(edit_item) .service(edit_form)
.service(edit_item_post) .service(edit)
.service(delete_item); .service(delete);
} }
#[get("/item/{id}")] #[get("/item/{id}")]
async fn show_item( async fn show(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
user: Identity, user: Identity,
@ -123,7 +123,7 @@ async fn show_item(
} }
#[get("/items")] #[get("/items")]
async fn list_items(pool: web::Data<PgPool>, user: Identity) -> actix_web::Result<impl Responder> { async fn list(pool: web::Data<PgPool>, user: Identity) -> actix_web::Result<impl Responder> {
let item_list = manage::item::get_all(&pool) let item_list = manage::item::get_all(&pool)
.await .await
.map_err(error::ErrorInternalServerError)?; .map_err(error::ErrorInternalServerError)?;
@ -199,7 +199,7 @@ async fn list_items(pool: web::Data<PgPool>, user: Identity) -> actix_web::Resul
} }
#[get("/items/add")] #[get("/items/add")]
async fn add_item( async fn add_form(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
form: web::Query<NewItemForm>, form: web::Query<NewItemForm>,
user: Identity, user: Identity,
@ -255,7 +255,7 @@ async fn add_item(
} }
#[post("/items/add")] #[post("/items/add")]
async fn add_item_post( async fn add_post(
data: web::Form<NewItem>, data: web::Form<NewItem>,
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
_user: Identity, _user: Identity,
@ -267,7 +267,7 @@ async fn add_item_post(
} }
#[get("/item/{id}/edit")] #[get("/item/{id}/edit")]
async fn edit_item( async fn edit_form(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
user: Identity, user: Identity,
@ -348,7 +348,7 @@ async fn edit_item(
} }
#[post("/item/{id}/edit")] #[post("/item/{id}/edit")]
async fn edit_item_post( async fn edit(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
data: web::Form<NewItem>, data: web::Form<NewItem>,
@ -364,7 +364,7 @@ async fn edit_item_post(
} }
#[post("/item/{id}/delete")] #[post("/item/{id}/delete")]
async fn delete_item( async fn delete(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
_user: Identity, _user: Identity,

View file

@ -14,17 +14,17 @@ use crate::manage;
use crate::models::*; use crate::models::*;
pub fn config(cfg: &mut web::ServiceConfig) { pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(show_item_class) cfg.service(show)
.service(list_item_classes) .service(list)
.service(add_item_class) .service(add_form)
.service(add_item_class_post) .service(add)
.service(edit_item_class) .service(edit_form)
.service(edit_item_class_post) .service(edit)
.service(delete_item_class); .service(delete);
} }
#[get("/item-class/{id}")] #[get("/item-class/{id}")]
async fn show_item_class( async fn show(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
user: Identity, user: Identity,
@ -123,10 +123,7 @@ async fn show_item_class(
} }
#[get("/item-classes")] #[get("/item-classes")]
async fn list_item_classes( async fn list(pool: web::Data<PgPool>, user: Identity) -> actix_web::Result<impl Responder> {
pool: web::Data<PgPool>,
user: Identity,
) -> actix_web::Result<impl Responder> {
let item_classes_ids = sqlx::query_scalar!("SELECT id FROM item_classes ORDER BY created_at") let item_classes_ids = sqlx::query_scalar!("SELECT id FROM item_classes ORDER BY created_at")
.fetch_all(pool.as_ref()) .fetch_all(pool.as_ref())
.await .await
@ -182,7 +179,7 @@ async fn list_item_classes(
} }
#[get("/item-classes/add")] #[get("/item-classes/add")]
async fn add_item_class( async fn add_form(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
form: web::Query<NewItemClassForm>, form: web::Query<NewItemClassForm>,
user: Identity, user: Identity,
@ -227,7 +224,7 @@ async fn add_item_class(
} }
#[post("/item-classes/add")] #[post("/item-classes/add")]
async fn add_item_class_post( async fn add(
data: web::Form<NewItemClass>, data: web::Form<NewItemClass>,
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
_user: Identity, _user: Identity,
@ -239,7 +236,7 @@ async fn add_item_class_post(
} }
#[get("/item-class/{id}/edit")] #[get("/item-class/{id}/edit")]
async fn edit_item_class( async fn edit_form(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
user: Identity, user: Identity,
@ -302,7 +299,7 @@ async fn edit_item_class(
} }
#[post("/item-class/{id}/edit")] #[post("/item-class/{id}/edit")]
async fn edit_item_class_post( async fn edit(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
data: web::Form<NewItemClass>, data: web::Form<NewItemClass>,
@ -318,7 +315,7 @@ async fn edit_item_class_post(
} }
#[post("/item-class/{id}/delete")] #[post("/item-class/{id}/delete")]
async fn delete_item_class( async fn delete(
pool: web::Data<PgPool>, pool: web::Data<PgPool>,
path: web::Path<Uuid>, path: web::Path<Uuid>,
_user: Identity, _user: Identity,