fixed up the featured artist thing
This commit is contained in:
@@ -376,14 +376,18 @@ pub async fn enrich_artist(
|
||||
.await;
|
||||
tracing::debug!(mbid = %mbid, has_photo = artist_photo.is_some(), has_bio = artist_bio.is_some(), has_banner = artist_banner.is_some(), "artist enrichment data");
|
||||
|
||||
// Fetch release groups and filter by allowed secondary types
|
||||
// Fetch release groups and split into primary vs featured
|
||||
let all_release_groups = state
|
||||
.search
|
||||
.get_release_groups(&mbid)
|
||||
.await
|
||||
.map_err(|e| ApiError::Internal(e.to_string()))?;
|
||||
let allowed = state.config.read().await.allowed_secondary_types.clone();
|
||||
let release_groups: Vec<_> = all_release_groups
|
||||
|
||||
let (primary_rgs, featured_rgs): (Vec<_>, Vec<_>) =
|
||||
all_release_groups.into_iter().partition(|rg| !rg.featured);
|
||||
|
||||
let release_groups: Vec<_> = primary_rgs
|
||||
.into_iter()
|
||||
.filter(|rg| {
|
||||
if rg.secondary_types.is_empty() {
|
||||
@@ -395,6 +399,31 @@ pub async fn enrich_artist(
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Featured release groups — just pass through with type filtering
|
||||
let featured_albums: Vec<FullAlbumInfo> = featured_rgs
|
||||
.iter()
|
||||
.filter(|rg| {
|
||||
if rg.secondary_types.is_empty() {
|
||||
true
|
||||
} else {
|
||||
rg.secondary_types.iter().all(|st| allowed.contains(st))
|
||||
}
|
||||
})
|
||||
.map(|rg| FullAlbumInfo {
|
||||
mbid: rg.first_release_id.clone().unwrap_or_else(|| rg.id.clone()),
|
||||
title: rg.title.clone(),
|
||||
release_type: rg.primary_type.clone(),
|
||||
date: rg.first_release_date.clone(),
|
||||
track_count: 0,
|
||||
local_album_id: None,
|
||||
watched_tracks: 0,
|
||||
owned_tracks: 0,
|
||||
downloaded_tracks: 0,
|
||||
total_local_tracks: 0,
|
||||
status: "featured".to_string(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Get all wanted items for this artist
|
||||
let all_wanted = queries::wanted::list(state.db.conn(), None, None).await?;
|
||||
let artist_wanted: Vec<_> = all_wanted
|
||||
@@ -609,6 +638,7 @@ pub async fn enrich_artist(
|
||||
Ok(serde_json::json!({
|
||||
"artist": artist,
|
||||
"albums": albums,
|
||||
"featured_albums": featured_albums,
|
||||
"artist_status": artist_status,
|
||||
"total_available_tracks": total_available_tracks,
|
||||
"total_watched_tracks": total_artist_watched,
|
||||
|
||||
Reference in New Issue
Block a user