summaryrefslogtreecommitdiff
path: root/src/routes/song.rs
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-20 13:33:39 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-20 13:33:39 +0100
commitdaa7aea33439a91c4dd14592d1909d78ebe472e2 (patch)
tree352af9d17fd73b0f69b2e013110a17df0a82e7b5 /src/routes/song.rs
parent6ca868c03ab4bc9ead99ef81c28560abf6fa0943 (diff)
replace useless function (check_if_exists)
Diffstat (limited to 'src/routes/song.rs')
-rw-r--r--src/routes/song.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/routes/song.rs b/src/routes/song.rs
index 8cb34bf..27197dd 100644
--- a/src/routes/song.rs
+++ b/src/routes/song.rs
@@ -18,19 +18,19 @@ pub async fn song(
) -> HttpResponse {
let default: String = String::from("");
let search_attempt: sqlx::Result<Vec<Song>> = match true {
- _ if check_if_exists(&get_args.id) => {
+ _ if get_args.id.is_some() => {
let id: &str = &get_args.id.as_ref().unwrap_or(&default);
app_state.database.select_song_by_id(id).await
}
- _ if check_if_exists(&get_args.name) => {
+ _ if get_args.name.is_some() => {
let name: &str = &get_args.name.as_ref().unwrap_or(&default);
app_state.database.select_songs_by_name(name).await
}
- _ if check_if_exists(&get_args.album) => {
+ _ if get_args.album.is_some() => {
let album: &str = &get_args.album.as_ref().unwrap_or(&default);
app_state.database.select_songs_by_album(album).await
}
- _ if check_if_exists(&get_args.artist) => {
+ _ if get_args.artist.is_some() => {
let artist: &str = &get_args.artist.as_ref().unwrap_or(&default);
app_state.database.select_songs_by_artist(artist).await
}
@@ -42,10 +42,3 @@ pub async fn song(
Err(e) => HttpResponse::Ok().body(format!("{}", e)),
}
}
-
-fn check_if_exists(value: &Option<String>) -> bool {
- match value {
- Some(_) => true,
- None => false,
- }
-}