From e8fdc4532a64b35daaaa47fab56c7ec0930470fa Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Tue, 18 Jun 2024 23:56:38 +0200 Subject: [PATCH] feat(*): remove read on location --- frontend/templates/person.html | 6 ------ frontend/templates/persons.html | 6 ------ person/src/main.rs | 11 ++++------- person/src/person.rs | 1 - 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/frontend/templates/person.html b/frontend/templates/person.html index 8d46d73..936f4d5 100644 --- a/frontend/templates/person.html +++ b/frontend/templates/person.html @@ -2,11 +2,5 @@

{{ person.last_name }}

{{ person.phone_number }}

- {% match person.location %} - {% when Some with (loc) %} -

{{ loc }}

- {% else %} -

No location

- {% endmatch %}
diff --git a/frontend/templates/persons.html b/frontend/templates/persons.html index b223874..b0e2535 100644 --- a/frontend/templates/persons.html +++ b/frontend/templates/persons.html @@ -11,12 +11,6 @@

People

{{ person.last_name }}

{{ person.phone_number }}

- {% match person.location %} - {% when Some with (loc) %} -

{{ loc }}

- {% else %} -

No location

- {% endmatch %}
{% endfor %} diff --git a/person/src/main.rs b/person/src/main.rs index 91c937b..bbfde4a 100644 --- a/person/src/main.rs +++ b/person/src/main.rs @@ -56,7 +56,7 @@ struct Args { async fn create_person(pool: &PgPool, person: CreatePersonDto) -> Result { let person = sqlx::query_as!( Person, - "INSERT INTO person (last_name, phone_number) VALUES ($1, $2) RETURNING *", + "INSERT INTO person (last_name, phone_number) VALUES ($1, $2) RETURNING id, last_name, phone_number", person.last_name, person.phone_number, ) @@ -66,12 +66,9 @@ async fn create_person(pool: &PgPool, person: CreatePersonDto) -> Result Result, sqlx::Error> { - let persons = sqlx::query_as!( - Person, - "SELECT id, last_name, phone_number, location FROM person" - ) - .fetch_all(pool) - .await?; + let persons = sqlx::query_as!(Person, "SELECT id, last_name, phone_number FROM person") + .fetch_all(pool) + .await?; Ok(persons) } diff --git a/person/src/person.rs b/person/src/person.rs index 45f579d..fa65f76 100644 --- a/person/src/person.rs +++ b/person/src/person.rs @@ -11,5 +11,4 @@ pub struct Person { pub id: i32, pub last_name: String, pub phone_number: String, - pub location: Option, }