feat: Fetch the artist members as part of the artist details query
This commit is contained in:
@@ -26,6 +26,7 @@ pub struct Artist {
|
|||||||
pub overview: Option<String>,
|
pub overview: Option<String>,
|
||||||
pub artist_type: Option<String>,
|
pub artist_type: Option<String>,
|
||||||
pub disambiguation: Option<String>,
|
pub disambiguation: Option<String>,
|
||||||
|
pub members: Option<Vec<Member>>,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
#[serde(deserialize_with = "super::from_i64")]
|
#[serde(deserialize_with = "super::from_i64")]
|
||||||
pub quality_profile_id: i64,
|
pub quality_profile_id: i64,
|
||||||
@@ -63,6 +64,15 @@ pub struct Ratings {
|
|||||||
|
|
||||||
impl Eq for Ratings {}
|
impl Eq for Ratings {}
|
||||||
|
|
||||||
|
#[derive(Derivative, Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Member {
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub instrument: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for Member {}
|
||||||
|
|
||||||
#[derive(Derivative, Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
|
#[derive(Derivative, Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ArtistStatistics {
|
pub struct ArtistStatistics {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ mod tests {
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::models::lidarr_models::{
|
use crate::models::lidarr_models::{
|
||||||
DownloadRecord, DownloadStatus, DownloadsResponse, MetadataProfile, NewItemMonitorType,
|
DownloadRecord, DownloadStatus, DownloadsResponse, Member, MetadataProfile, NewItemMonitorType,
|
||||||
SystemStatus,
|
SystemStatus,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::{DiskSpace, QualityProfile, RootFolder, Tag};
|
use crate::models::servarr_models::{DiskSpace, QualityProfile, RootFolder, Tag};
|
||||||
@@ -74,7 +74,6 @@ mod tests {
|
|||||||
fn test_artist_deserialization() {
|
fn test_artist_deserialization() {
|
||||||
let artist_json = json!({
|
let artist_json = json!({
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"mbId": "test-mb-id",
|
|
||||||
"artistName": "Test Artist",
|
"artistName": "Test Artist",
|
||||||
"foreignArtistId": "test-foreign-id",
|
"foreignArtistId": "test-foreign-id",
|
||||||
"status": "continuing",
|
"status": "continuing",
|
||||||
@@ -82,6 +81,10 @@ mod tests {
|
|||||||
"artistType": "Group",
|
"artistType": "Group",
|
||||||
"disambiguation": "UK Band",
|
"disambiguation": "UK Band",
|
||||||
"path": "/music/test-artist",
|
"path": "/music/test-artist",
|
||||||
|
"members": [
|
||||||
|
{ "name": "alex", "instrument": "piano" },
|
||||||
|
{ "name": "madi", "instrument": "vocals" }
|
||||||
|
],
|
||||||
"qualityProfileId": 1,
|
"qualityProfileId": 1,
|
||||||
"metadataProfileId": 1,
|
"metadataProfileId": 1,
|
||||||
"monitored": true,
|
"monitored": true,
|
||||||
@@ -102,6 +105,16 @@ mod tests {
|
|||||||
"percentOfTracks": 83.33
|
"percentOfTracks": 83.33
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let expected_members_vec = vec![
|
||||||
|
Member {
|
||||||
|
name: Some("alex".to_string()),
|
||||||
|
instrument: Some("piano".to_string()),
|
||||||
|
},
|
||||||
|
Member {
|
||||||
|
name: Some("madi".to_string()),
|
||||||
|
instrument: Some("vocals".to_string()),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
let artist: Artist = serde_json::from_value(artist_json).unwrap();
|
let artist: Artist = serde_json::from_value(artist_json).unwrap();
|
||||||
|
|
||||||
@@ -113,6 +126,7 @@ mod tests {
|
|||||||
assert_some_eq_x!(&artist.artist_type, "Group");
|
assert_some_eq_x!(&artist.artist_type, "Group");
|
||||||
assert_some_eq_x!(&artist.disambiguation, "UK Band");
|
assert_some_eq_x!(&artist.disambiguation, "UK Band");
|
||||||
assert_str_eq!(artist.path, "/music/test-artist");
|
assert_str_eq!(artist.path, "/music/test-artist");
|
||||||
|
assert_some_eq_x!(&artist.members, &expected_members_vec);
|
||||||
assert_eq!(artist.quality_profile_id, 1);
|
assert_eq!(artist.quality_profile_id, 1);
|
||||||
assert_eq!(artist.metadata_profile_id, 1);
|
assert_eq!(artist.metadata_profile_id, 1);
|
||||||
assert!(artist.monitored);
|
assert!(artist.monitored);
|
||||||
@@ -198,7 +212,6 @@ mod tests {
|
|||||||
fn test_artist_with_optional_fields_none() {
|
fn test_artist_with_optional_fields_none() {
|
||||||
let artist_json = json!({
|
let artist_json = json!({
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"mbId": "",
|
|
||||||
"artistName": "Test Artist",
|
"artistName": "Test Artist",
|
||||||
"foreignArtistId": "",
|
"foreignArtistId": "",
|
||||||
"status": "continuing",
|
"status": "continuing",
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ mod tests {
|
|||||||
async fn test_handle_list_artists_event() {
|
async fn test_handle_list_artists_event() {
|
||||||
let artists_json = json!([{
|
let artists_json = json!([{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"mbId": "test-mb-id",
|
|
||||||
"artistName": "Test Artist",
|
"artistName": "Test Artist",
|
||||||
"foreignArtistId": "test-foreign-id",
|
"foreignArtistId": "test-foreign-id",
|
||||||
"status": "continuing",
|
"status": "continuing",
|
||||||
@@ -73,18 +72,30 @@ mod tests {
|
|||||||
async fn test_handle_get_artist_details_event() {
|
async fn test_handle_get_artist_details_event() {
|
||||||
let artist_json = json!({
|
let artist_json = json!({
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"mbId": "test-mb-id",
|
|
||||||
"artistName": "Test Artist",
|
"artistName": "Test Artist",
|
||||||
"foreignArtistId": "test-foreign-id",
|
"foreignArtistId": "test-foreign-id",
|
||||||
"status": "continuing",
|
"status": "continuing",
|
||||||
|
"overview": "some interesting description of the artist",
|
||||||
|
"artistType": "Person",
|
||||||
|
"disambiguation": "American pianist",
|
||||||
"path": "/music/test-artist",
|
"path": "/music/test-artist",
|
||||||
|
"members": [{"name": "alex", "instrument": "piano"}],
|
||||||
"qualityProfileId": 1,
|
"qualityProfileId": 1,
|
||||||
"metadataProfileId": 1,
|
"metadataProfileId": 1,
|
||||||
"monitored": true,
|
"monitored": true,
|
||||||
"monitorNewItems": "all",
|
"monitorNewItems": "all",
|
||||||
"genres": [],
|
"genres": ["soundtrack"],
|
||||||
"tags": [],
|
"tags": [1],
|
||||||
"added": "2023-01-01T00:00:00Z"
|
"added": "2023-01-01T00:00:00Z",
|
||||||
|
"ratings": { "votes": 15, "value": 8.4 },
|
||||||
|
"statistics": {
|
||||||
|
"albumCount": 1,
|
||||||
|
"trackFileCount": 15,
|
||||||
|
"trackCount": 15,
|
||||||
|
"totalTrackCount": 15,
|
||||||
|
"sizeOnDisk": 12345,
|
||||||
|
"percentOfTracks": 99.9
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let response: Artist = serde_json::from_value(artist_json.clone()).unwrap();
|
let response: Artist = serde_json::from_value(artist_json.clone()).unwrap();
|
||||||
let (mock, app, _server) = MockServarrApi::get()
|
let (mock, app, _server) = MockServarrApi::get()
|
||||||
@@ -112,7 +123,6 @@ mod tests {
|
|||||||
async fn test_handle_toggle_artist_monitoring_event() {
|
async fn test_handle_toggle_artist_monitoring_event() {
|
||||||
let artist_json = json!({
|
let artist_json = json!({
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"mbId": "test-mb-id",
|
|
||||||
"artistName": "Test Artist",
|
"artistName": "Test Artist",
|
||||||
"foreignArtistId": "test-foreign-id",
|
"foreignArtistId": "test-foreign-id",
|
||||||
"status": "continuing",
|
"status": "continuing",
|
||||||
|
|||||||
Reference in New Issue
Block a user