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::*;
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<PgPool>,
path: web::Path<Uuid>,
user: Identity,
@ -123,7 +123,7 @@ async fn show_item(
}
#[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)
.await
.map_err(error::ErrorInternalServerError)?;
@ -199,7 +199,7 @@ async fn list_items(pool: web::Data<PgPool>, user: Identity) -> actix_web::Resul
}
#[get("/items/add")]
async fn add_item(
async fn add_form(
pool: web::Data<PgPool>,
form: web::Query<NewItemForm>,
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<NewItem>,
pool: web::Data<PgPool>,
_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<PgPool>,
path: web::Path<Uuid>,
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<PgPool>,
path: web::Path<Uuid>,
data: web::Form<NewItem>,
@ -364,7 +364,7 @@ async fn edit_item_post(
}
#[post("/item/{id}/delete")]
async fn delete_item(
async fn delete(
pool: web::Data<PgPool>,
path: web::Path<Uuid>,
_user: Identity,

View file

@ -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<PgPool>,
path: web::Path<Uuid>,
user: Identity,
@ -123,10 +123,7 @@ async fn show_item_class(
}
#[get("/item-classes")]
async fn list_item_classes(
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_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<PgPool>,
form: web::Query<NewItemClassForm>,
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<NewItemClass>,
pool: web::Data<PgPool>,
_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<PgPool>,
path: web::Path<Uuid>,
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<PgPool>,
path: web::Path<Uuid>,
data: web::Form<NewItemClass>,
@ -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<PgPool>,
path: web::Path<Uuid>,
_user: Identity,