-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: fix linting error for ContactWithId
I think `Indexed` and `IndexContact` are better Though something I noticed is that when debugging the default display says `Indexed` isn't descriptive Later when logging becomes important i'll look into it
- Loading branch information
1 parent
63f348e
commit ac6533c
Showing
4 changed files
with
15 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ use sqlx::postgres::PgPool; | |
#[async_trait] | ||
pub trait ContactRepo { | ||
async fn save_contact(&self, contact: models::Contact) -> anyhow::Result<i64>; | ||
async fn get_all(&self) -> anyhow::Result<Vec<models::ContactWithId>>; | ||
async fn get_all(&self) -> anyhow::Result<Vec<models::IndexedContact>>; | ||
} | ||
|
||
pub struct PostgresContactRepo { | ||
|
@@ -43,15 +43,14 @@ impl ContactRepo for PostgresContactRepo { | |
Ok(id) | ||
} | ||
|
||
async fn get_all(&self) -> anyhow::Result<Vec<models::ContactWithId>> { | ||
let get_contacts_query = r#" | ||
SELECT id, first_name, last_name, display_name, email, phone_number | ||
FROM contacts | ||
ORDER BY id | ||
"#; | ||
async fn get_all(&self) -> anyhow::Result<Vec<models::IndexedContact>> { | ||
let get_contacts_query = | ||
"SELECT id, first_name, last_name, display_name, email, phone_number | ||
FROM contacts | ||
ORDER BY id"; | ||
|
||
let contacts_with_id: Vec<models::ContactWithId> = | ||
sqlx::query_as::<_, models::ContactWithId>(get_contacts_query) | ||
let contacts_with_id: Vec<models::IndexedContact> = | ||
sqlx::query_as::<_, models::IndexedContact>(get_contacts_query) | ||
.fetch_all(&*self.pg_pool) | ||
.await?; | ||
|
||
|
@@ -88,7 +87,7 @@ mod tests { | |
async fn test_get_all_contacts() { | ||
let mut mock_contact_repo = MockContactRepo::new(); | ||
|
||
let contacts = vec![models::ContactWithId { | ||
let contacts = vec![models::IndexedContact { | ||
id: 1, | ||
contact: models::Contact::new("John", "Doe", "[email protected]", "1234567890") | ||
.unwrap(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod contact; | ||
|
||
pub use contact::{Contact, ContactWithId}; | ||
pub use contact::Contact; | ||
pub use contact::Indexed as IndexedContact; |