Song queue #258
@@ -160,7 +160,6 @@ pub mod endpoint {
|
|||||||
match super::is_song_valid(&raw_data).await {
|
match super::is_song_valid(&raw_data).await {
|
||||||
Ok(valid) => {
|
Ok(valid) => {
|
||||||
if valid {
|
if valid {
|
||||||
println!("Go");
|
|
||||||
match repo::song::insert(
|
match repo::song::insert(
|
||||||
&pool,
|
&pool,
|
||||||
&file_name,
|
&file_name,
|
||||||
@@ -179,23 +178,13 @@ pub mod endpoint {
|
|||||||
raw_data: copied_raw_data,
|
raw_data: copied_raw_data,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
let filename = simodels::song::generate_filename(
|
|
||||||
simodels::types::MusicType::FlacExtension,
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
*/
|
|
||||||
println!("Filename: {file_name:?}");
|
println!("Filename: {file_name:?}");
|
||||||
let file_path = format!("queued/song/{file_name}");
|
let file_path = format!("queued/song/{file_name}");
|
||||||
println!("Path: {file_path:?}");
|
println!("Path: {file_path:?}");
|
||||||
|
|
||||||
match lr.upload(&file_path, &data).await {
|
match lr.upload(&file_path, &data).await {
|
||||||
Ok(res) => {
|
Ok(_res) => {
|
||||||
println!("Result: {res:?}");
|
|
||||||
|
|
||||||
println!("Saving to db");
|
|
||||||
|
|
||||||
match repo::data::insert(
|
match repo::data::insert(
|
||||||
&pool,
|
&pool,
|
||||||
&file_path,
|
&file_path,
|
||||||
|
|||||||
@@ -251,53 +251,3 @@ pub async fn get_song_queue(
|
|||||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
Err(_err) => Err(sqlx::Error::RowNotFound),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
pub async fn wipe_data(pool: &sqlx::PgPool, id: &uuid::Uuid) -> Result<uuid::Uuid, sqlx::Error> {
|
|
||||||
let result = sqlx::query(
|
|
||||||
r#"
|
|
||||||
UPDATE "songQueue" SET data = NULL WHERE id = $1 RETURNING id;
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.bind(id)
|
|
||||||
.fetch_one(pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| {
|
|
||||||
eprintln!("Error updating record: {e}");
|
|
||||||
});
|
|
||||||
|
|
||||||
match result {
|
|
||||||
Ok(row) => Ok(row
|
|
||||||
.try_get("id")
|
|
||||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
|
||||||
.unwrap()),
|
|
||||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_data(pool: &sqlx::PgPool, id: &uuid::Uuid) -> Result<Vec<u8>, sqlx::Error> {
|
|
||||||
let result = sqlx::query(
|
|
||||||
r#"
|
|
||||||
SELECT data FROM "songQueue"
|
|
||||||
WHERE id = $1;
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.bind(id)
|
|
||||||
.fetch_one(pool)
|
|
||||||
.await
|
|
||||||
.map_err(|e| {
|
|
||||||
eprintln!("Error inserting: {e}");
|
|
||||||
});
|
|
||||||
|
|
||||||
match result {
|
|
||||||
Ok(row) => {
|
|
||||||
let data = row
|
|
||||||
.try_get("data")
|
|
||||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
|
||||||
.unwrap();
|
|
||||||
Ok(data)
|
|
||||||
}
|
|
||||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user