Wipe data from song queue (#35)
Some checks failed
Release Tagging / release (push) Successful in 33s
Rust Build / Check (push) Failing after 35s
Rust Build / Test Suite (push) Failing after 41s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Failing after 41s
Rust Build / build (push) Failing after 40s
Rust Build / Check (pull_request) Failing after 36s
Rust Build / Test Suite (pull_request) Failing after 37s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 34s
Rust Build / build (pull_request) Failing after 35s
Some checks failed
Release Tagging / release (push) Successful in 33s
Rust Build / Check (push) Failing after 35s
Rust Build / Test Suite (push) Failing after 41s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Failing after 41s
Rust Build / build (push) Failing after 40s
Rust Build / Check (pull_request) Failing after 36s
Rust Build / Test Suite (pull_request) Failing after 37s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 34s
Rust Build / build (pull_request) Failing after 35s
Reviewed-on: #35 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1255,7 +1255,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "songparser"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"icarus_envy",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "songparser"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
edition = "2024"
|
||||
rust-version = "1.88"
|
||||
|
||||
|
32
src/main.rs
32
src/main.rs
@@ -31,6 +31,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
(coverart_queue_id, coverart_queue_path),
|
||||
)) => {
|
||||
// TODO: Wipe data from song and coverart queues
|
||||
match wipe_data_from_queues(
|
||||
&app_base_url,
|
||||
&song_queue_id,
|
||||
&coverart_queue_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
}
|
||||
// TODO: Cleanup files in local filesystem
|
||||
}
|
||||
Err(err) => {
|
||||
@@ -51,6 +63,26 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
async fn wipe_data_from_queues(
|
||||
app_base_url: &String,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
coverart_queue_id: &uuid::Uuid,
|
||||
) -> Result<(), std::io::Error> {
|
||||
match the_rest::wipe_data::song_queue::wipe_data(app_base_url, song_queue_id).await {
|
||||
Ok(response) => match response
|
||||
.json::<the_rest::wipe_data::song_queue::response::Response>()
|
||||
.await
|
||||
{
|
||||
Ok(_resp) => {
|
||||
println!("Wiped data from song queue");
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
},
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
async fn is_queue_empty(
|
||||
api_url: &String,
|
||||
) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> {
|
||||
|
@@ -1,6 +1,5 @@
|
||||
// TODO: Refactor this file when this app is functional
|
||||
|
||||
// TODO: Create song
|
||||
pub mod create_song {
|
||||
pub async fn create(
|
||||
base_url: &String,
|
||||
@@ -44,7 +43,6 @@ pub mod create_song {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Create coverart
|
||||
pub mod create_coverart {
|
||||
|
||||
pub async fn create(
|
||||
@@ -76,5 +74,29 @@ pub mod create_coverart {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Wipe data from queued song
|
||||
pub mod wipe_data {
|
||||
pub mod song_queue {
|
||||
pub async fn wipe_data(
|
||||
base_url: &String,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<reqwest::Response, reqwest::Error> {
|
||||
let client = reqwest::Client::builder().build()?;
|
||||
let url = format!("{base_url}/api/v2/song/queue/data/wipe");
|
||||
let payload = serde_json::json!({
|
||||
"song_queue_id": song_queue_id
|
||||
});
|
||||
let request = client.patch(url).json(&payload);
|
||||
|
||||
request.send().await
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<uuid::Uuid>,
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Wipe data from queued coverart
|
||||
}
|
||||
|
Reference in New Issue
Block a user