summaryrefslogtreecommitdiff
path: root/src/routes/artist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/artist.rs')
-rw-r--r--src/routes/artist.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/routes/artist.rs b/src/routes/artist.rs
index 8d968ae..5f0b9a6 100644
--- a/src/routes/artist.rs
+++ b/src/routes/artist.rs
@@ -14,18 +14,16 @@ pub async fn artist(
app_state: web::Data<AppState>,
get_args: web::Query<ArtistQueryOptions>,
) -> HttpResponse {
+ let default: String = String::from("");
let search_attempt: sqlx::Result<Vec<Artist>, sqlx::Error> = match true {
_ if check_if_exists(&get_args.id) => {
- app_state
- .database
- .select_artist_by_id(&get_args.id.clone().unwrap())
- .await
+ let id: &str = &get_args.id.as_ref().unwrap_or(&default);
+
+ app_state.database.select_artist_by_id(id).await
}
_ if check_if_exists(&get_args.name) => {
- app_state
- .database
- .select_artists_by_name(&get_args.name.clone().unwrap())
- .await
+ let name: &str = &get_args.name.as_ref().unwrap_or(&default);
+ app_state.database.select_artists_by_name(name).await
}
_ => app_state.database.select_artists().await,
};