Minor API Fixes

This commit is contained in:
Neshura 2023-09-09 01:04:01 +02:00
parent 464f870c29
commit 5a557d262b
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
2 changed files with 5 additions and 16 deletions

View file

@ -986,12 +986,10 @@ pub(crate) async fn edit_empire(
let mut db_empire_query = QueryBuilder::<sqlx::Postgres>::new("UPDATE public.empires SET "); let mut db_empire_query = QueryBuilder::<sqlx::Postgres>::new("UPDATE public.empires SET ");
let mut db_empire_separated = db_empire_query.separated(", "); let mut db_empire_separated = db_empire_query.separated(", ");
if let Some(new_game) = params.game_id { // More often than not does nothing but is required to ensure data is handled properly
any_param_present = true; db_empire_separated
db_empire_separated .push(" game_id = ")
.push(" game_id = ") .push_bind_unseparated(params.game_id);
.push_bind_unseparated(new_game);
}
if let Some(new_group) = params.group_id { if let Some(new_group) = params.group_id {
any_param_present = true; any_param_present = true;
@ -1045,9 +1043,6 @@ pub(crate) async fn edit_empire(
db_empire_separated db_empire_separated
.push_unseparated(" WHERE id = ") .push_unseparated(" WHERE id = ")
.push_bind_unseparated(params.empire_id); .push_bind_unseparated(params.empire_id);
db_empire_separated
.push_unseparated(" AND group_id = ")
.push_bind_unseparated(params.group_id);
db_empire_separated db_empire_separated
.push_unseparated(" AND game_id = ") .push_unseparated(" AND game_id = ")
.push_bind_unseparated(params.game_id); .push_bind_unseparated(params.game_id);
@ -1070,9 +1065,6 @@ pub(crate) async fn edit_empire(
db_empire_separated db_empire_separated
.push_unseparated(" WHERE id = ") .push_unseparated(" WHERE id = ")
.push_bind_unseparated(params.empire_id); .push_bind_unseparated(params.empire_id);
db_empire_separated
.push_unseparated(" AND group_id = ")
.push_bind_unseparated(params.group_id);
db_empire_separated db_empire_separated
.push_unseparated(" AND game_id = ") .push_unseparated(" AND game_id = ")
.push_bind_unseparated(params.game_id); .push_bind_unseparated(params.game_id);
@ -1284,9 +1276,6 @@ pub(crate) async fn get_ethics(data: web::Data<AppState>) -> impl Responder {
responses( responses(
(status = 200, description = "OK", body = ChellarisPhenotypes), (status = 200, description = "OK", body = ChellarisPhenotypes),
), ),
security(
("api_key" = [])
),
)] )]
#[get("/api/v3/phenotypes")] #[get("/api/v3/phenotypes")]
pub(crate) async fn get_phenotypes(data: web::Data<AppState>) -> impl Responder { pub(crate) async fn get_phenotypes(data: web::Data<AppState>) -> impl Responder {

View file

@ -147,7 +147,7 @@ pub struct UpdateEmpireParams {
#[schema(example = 1)] #[schema(example = 1)]
pub empire_id: i32, pub empire_id: i32,
#[schema(example = 1)] #[schema(example = 1)]
pub game_id: Option<i32>, pub game_id: i32,
#[schema(example = 1)] #[schema(example = 1)]
pub group_id: Option<i32>, pub group_id: Option<i32>,
#[schema(example = "Example Empire")] #[schema(example = "Example Empire")]