From bcd960d9a112da0f09f82f1f94d00f628d1ef7af Mon Sep 17 00:00:00 2001 From: KD Date: Fri, 7 Nov 2025 11:48:07 -0500 Subject: [PATCH] tsk-245: Modify result when getting songs but no songs are present (#247) * tsk-245: Modify result when getting songs but no songs are present * tsk-245: Fixed endpoint indicating success when no content is found * tsk-245: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/callers/song.rs | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5395b8d..016840e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "icarus" -version = "0.3.27" +version = "0.3.28" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index 2bc9c48..9f5d8e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus" -version = "0.3.27" +version = "0.3.28" edition = "2024" rust-version = "1.90" diff --git a/src/callers/song.rs b/src/callers/song.rs index 69da51b..2aff68d 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -251,9 +251,14 @@ pub mod endpoint { match repo::song::get_all_songs(&pool).await { Ok(songs) => { - response.message = String::from(super::super::response::SUCCESSFUL); - response.data = songs; - (axum::http::StatusCode::OK, axum::Json(response)) + if songs.is_empty() { + response.message = String::from("No songs available"); + (axum::http::StatusCode::NOT_FOUND, axum::Json(response)) + } else { + response.message = String::from(super::super::response::SUCCESSFUL); + response.data = songs; + (axum::http::StatusCode::OK, axum::Json(response)) + } } Err(err) => { response.message = err.to_string();