Skip to content

Commit

Permalink
feat(*): remove read on location
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoreiradj committed Jun 18, 2024
1 parent 7cd94bc commit e8fdc45
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
6 changes: 0 additions & 6 deletions frontend/templates/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@
<div class="card-body">
<h2 class="card-title">{{ person.last_name }}</h2>
<h3 class="card-text">{{ person.phone_number }}</h3>
{% match person.location %}
{% when Some with (loc) %}
<p class="card-text">{{ loc }}</p>
{% else %}
<p class="card-text">No location</p>
{% endmatch %}
</div>
</div>
6 changes: 0 additions & 6 deletions frontend/templates/persons.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ <h1>People</h1>
<div class="card-body">
<h2 class="card-title">{{ person.last_name }}</h2>
<h3 class="card-text">{{ person.phone_number }}</h3>
{% match person.location %}
{% when Some with (loc) %}
<p class="card-text">{{ loc }}</p>
{% else %}
<p class="card-text">No location</p>
{% endmatch %}
</div>
</div>
{% endfor %}
Expand Down
11 changes: 4 additions & 7 deletions person/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct Args {
async fn create_person(pool: &PgPool, person: CreatePersonDto) -> Result<Person, sqlx::Error> {
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,
)
Expand All @@ -66,12 +66,9 @@ async fn create_person(pool: &PgPool, person: CreatePersonDto) -> Result<Person,
}

async fn list_persons(pool: &PgPool) -> Result<Vec<Person>, 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)
}

Expand Down
1 change: 0 additions & 1 deletion person/src/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ pub struct Person {
pub id: i32,
pub last_name: String,
pub phone_number: String,
pub location: Option<String>,
}

0 comments on commit e8fdc45

Please # to comment.