Refactoring #149
@@ -13,8 +13,6 @@ tokio = { version = "1.45.1", features = ["full"] }
|
|||||||
tokio-util = { version = "0.7.15" }
|
tokio-util = { version = "0.7.15" }
|
||||||
tower-http = { version = "0.6.6", features = ["timeout"] }
|
tower-http = { version = "0.6.6", features = ["timeout"] }
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
# mime = { version = "0.3.17" }
|
|
||||||
# mime_guess = { version = "2.0.5" }
|
|
||||||
futures = { version = "0.3.31" }
|
futures = { version = "0.3.31" }
|
||||||
uuid = { version = "1.17.0", features = ["v4", "serde"] }
|
uuid = { version = "1.17.0", features = ["v4", "serde"] }
|
||||||
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio-native-tls", "time", "uuid"] }
|
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio-native-tls", "time", "uuid"] }
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ pub mod db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e:?}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -163,7 +163,7 @@ pub mod db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error querying data: {:?}", e);
|
eprintln!("Error querying data: {e:?}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -194,7 +194,7 @@ pub mod db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error querying data: {:?}", e);
|
eprintln!("Error querying data: {e:?}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -225,7 +225,7 @@ pub mod db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error querying data: {:?}", e);
|
eprintln!("Error querying data: {e:?}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -250,7 +250,7 @@ pub mod db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error querying data: {:?}", e);
|
eprintln!("Error querying data: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -275,7 +275,7 @@ pub mod db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error updating query: {:?}", e);
|
eprintln!("Error updating query: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -307,7 +307,7 @@ pub mod cov_db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -461,7 +461,7 @@ pub mod endpoint {
|
|||||||
// TODO: Make the conent disposition more dynamic
|
// TODO: Make the conent disposition more dynamic
|
||||||
headers.insert(
|
headers.insert(
|
||||||
axum::http::header::CONTENT_DISPOSITION,
|
axum::http::header::CONTENT_DISPOSITION,
|
||||||
format!("attachment; filename=\"{}.jpg\"", id)
|
format!("attachment; filename=\"{id}.jpg\"")
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ pub mod metadata_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -135,7 +135,7 @@ pub mod metadata_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -174,7 +174,7 @@ pub mod metadata_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -241,7 +241,7 @@ pub mod endpoint {
|
|||||||
|
|
||||||
match params.id {
|
match params.id {
|
||||||
Some(id) => {
|
Some(id) => {
|
||||||
println!("Something works {:?}", id);
|
println!("Something works {id}");
|
||||||
|
|
||||||
match super::metadata_queue::get_with_id(&pool, &id).await {
|
match super::metadata_queue::get_with_id(&pool, &id).await {
|
||||||
Ok(item) => {
|
Ok(item) => {
|
||||||
|
|||||||
+12
-12
@@ -189,7 +189,7 @@ pub mod song_db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting query: {:?}", e);
|
eprintln!("Error inserting query: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -223,7 +223,7 @@ pub mod song_db {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error querying data: {:?}", e);
|
eprintln!("Error querying data: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -339,7 +339,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -369,7 +369,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {:?}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -401,7 +401,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -436,7 +436,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error selecting: {:?}", e);
|
eprintln!("Error selecting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -463,7 +463,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error updating record {:?}", e);
|
eprintln!("Error updating record {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -488,7 +488,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error querying data: {:?}", e);
|
eprintln!("Error querying data: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -523,7 +523,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error updating record: {:?}", e);
|
eprintln!("Error updating record: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -546,7 +546,7 @@ mod song_queue {
|
|||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
eprintln!("Error inserting: {}", e);
|
eprintln!("Error inserting: {e}");
|
||||||
});
|
});
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
@@ -641,7 +641,7 @@ pub mod endpoint {
|
|||||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
||||||
) -> (StatusCode, axum::response::Response) {
|
) -> (StatusCode, axum::response::Response) {
|
||||||
println!("Id: {:?}", id);
|
println!("Id: {id}");
|
||||||
|
|
||||||
match song_queue::get_data(&pool, &id).await {
|
match song_queue::get_data(&pool, &id).await {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
@@ -654,7 +654,7 @@ pub mod endpoint {
|
|||||||
);
|
);
|
||||||
headers.insert(
|
headers.insert(
|
||||||
axum::http::header::CONTENT_DISPOSITION,
|
axum::http::header::CONTENT_DISPOSITION,
|
||||||
format!("attachment; filename=\"{}.flac\"", id)
|
format!("attachment; filename=\"{id}.flac\"")
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ pub mod db {
|
|||||||
|
|
||||||
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
let database_url = icarus_envy::environment::get_db_url().await;
|
let database_url = icarus_envy::environment::get_db_url().await;
|
||||||
println!("Database url: {:?}", database_url);
|
println!("Database url: {database_url}");
|
||||||
|
|
||||||
PgPoolOptions::new()
|
PgPoolOptions::new()
|
||||||
.max_connections(connection_settings::MAXCONN)
|
.max_connections(connection_settings::MAXCONN)
|
||||||
|
|||||||
Reference in New Issue
Block a user