diff options
Diffstat (limited to 'src/routes/album.rs')
-rw-r--r-- | src/routes/album.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/routes/album.rs b/src/routes/album.rs index d826f24..6f793bd 100644 --- a/src/routes/album.rs +++ b/src/routes/album.rs @@ -17,15 +17,15 @@ pub async fn album( ) -> HttpResponse { let default: String = String::from(""); let search_attempt: sqlx::Result<Vec<Album>, sqlx::Error> = 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_album_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_albums_by_name(name).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_albums_by_artist(artist).await } @@ -37,10 +37,3 @@ pub async fn album( Err(e) => HttpResponse::Ok().body(format!("{}", e)), } } - -fn check_if_exists(value: &Option<String>) -> bool { - match value { - Some(_) => true, - None => false, - } -} |