Saving changes
Rust Build / Test Suite (pull_request) Failing after 59s
Rust Build / Check (pull_request) Failing after 1m5s
Rust Build / Clippy (pull_request) Failing after 38s
Rust Build / Rustfmt (pull_request) Successful in 2m11s
Rust Build / build (pull_request) Failing after 1m31s

This commit is contained in:
2026-06-13 15:05:47 -04:00
parent ac250bb03e
commit cf1a637432
3 changed files with 30 additions and 44 deletions
+1
View File
@@ -0,0 +1 @@
+3 -1
View File
@@ -5,7 +5,9 @@ pub mod connection_settings {
} }
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> { pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
let database_url = textsender_models::envy::environment::get_db_url().await.value; let database_url = textsender_models::envy::environment::get_db_url()
.await
.value;
println!("Database url: {database_url}"); println!("Database url: {database_url}");
PgPoolOptions::new() PgPoolOptions::new()
+26 -43
View File
@@ -1,48 +1,31 @@
pub async fn insert( pub mod contact {
pool: &sqlx::PgPool, pub async fn insert(
song: &icarus_models::song::Song, pool: &sqlx::PgPool,
) -> Result<(time::OffsetDateTime, uuid::Uuid), sqlx::Error> { contact: &textsender_models::contact::Contact,
let result = sqlx::query( ) -> Result<(), sqlx::Error> {
r#" let result = sqlx::query(
INSERT INTO "song" (title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, filename, directory, user_id) r#"
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) RETURNING date_created, id; INSERT INTO "contacts" (firstname, lastname, nickname, phone_number, user_id)
"# VALUES($1, $2, $3, $4, $5);
"#,
) )
.bind(&song.title) .bind(&contact.firstname)
.bind(&song.artist) .bind(&contact.lastname)
.bind(&song.album_artist) .bind(&contact.nickname)
.bind(&song.album) .bind(&contact.phone_number)
.bind(&song.genre) .bind(&contact.user_id)
.bind(song.year) .execute(pool)
.bind(song.track) .await;
.bind(song.disc)
.bind(song.track_count)
.bind(song.disc_count)
.bind(song.duration)
.bind(&song.audio_type)
.bind(&song.filename)
.bind(&song.directory)
.bind(song.user_id)
.fetch_one(pool)
.await
.map_err(|e| {
eprintln!("Error inserting query: {e}");
});
match result { match result {
Ok(row) => { Ok(row) => {
let id: uuid::Uuid = row if row.rows_affected() > 0 {
.try_get("id") Ok(())
.map_err(|_e| sqlx::Error::RowNotFound) } else {
.unwrap(); Err(sqlx::Error::RowNotFound)
let date_created_time: time::OffsetDateTime = row }
.try_get("date_created") }
.map_err(|_e| sqlx::Error::RowNotFound) Err(_) => Err(sqlx::Error::RowNotFound),
.unwrap();
let date_created = date_created_time;
Ok((date_created, id))
} }
Err(_) => Err(sqlx::Error::RowNotFound),
} }
} }