Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix artist search when lastfm information isn't available #1554

Merged
merged 5 commits into from
Feb 24, 2024

Conversation

sferra
Copy link
Contributor

@sferra sferra commented Feb 16, 2024

Addresses #1427

@nukeop nukeop added the under review This pull request is being reviewed by maintainers. label Feb 16, 2024
@sferra
Copy link
Contributor Author

sferra commented Feb 16, 2024

I just added a few checks and extracted the some of the existing logic to a separate function to allow testing it later.

Copy link

codecov bot commented Feb 17, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 71.82%. Comparing base (d01e199) to head (26392a8).

Files Patch % Lines
packages/core/src/plugins/meta/discogs.ts 86.36% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1554      +/-   ##
==========================================
+ Coverage   71.60%   71.82%   +0.21%     
==========================================
  Files         364      364              
  Lines        6713     6729      +16     
  Branches      479      483       +4     
==========================================
+ Hits         4807     4833      +26     
+ Misses       1512     1500      -12     
- Partials      394      396       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nukeop nukeop removed the under review This pull request is being reviewed by maintainers. label Feb 18, 2024
Repository owner deleted a comment from nuki-chan bot Feb 18, 2024
@nukeop
Copy link
Owner

nukeop commented Feb 18, 2024

Should I start reviewing? Or do you want to mark it as ready later one when you finish?

@sferra sferra marked this pull request as ready for review February 18, 2024 23:26
@sferra
Copy link
Contributor Author

sferra commented Feb 18, 2024

I did my best to add tests for the my changes but I had to refactor.
Any feedback is appreciated, since I have no prior experience with TypeScript.

packages/core/src/plugins/meta/discogs.test.ts Outdated Show resolved Hide resolved
similar: {
artist: similarArtistsOnLastFm
}
} as any;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to use const artistInfoFromLastFm: SimilarArtist = {, or at least add satisfies SimilarArtist at the end. If the version of TS we're using is too old to have the satisfies keyword, you might be able to use as SimilarArtist.

The same method applies to the as any uses below. In general we want all objects to have appropriate types.

If the existing SimilarArtist type doesn't have the fields you need, you should add them there so that it reflects the type of data you want to return from getSimilarArtists. Or you can create a new type for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing the issues out. The actual type is LastFmArtistInfo which has multiple fields which are not relevant to the call and I didn't want to declare. satisfies doesn't seem to be appropriate here, or I don't know how to apply it. I addressed all as any casts with explicit types. Is that allright?

packages/core/src/plugins/meta/discogs.ts Outdated Show resolved Hide resolved
describe('Tests for DiscogsMetaProvider', () => {
const provider = new DiscogsMetaProvider();

describe('Verify if an artist is on tour', () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's needed to unit test small functions like this. Integration tests are more comprehensive, and this function is already included in the output of fetchArtistDetails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested only the code which I added or had to touch. The expression wrapped in the function was one of the things which caused the issue because of the missing lastFmInfo. So it's most certainly not yet covered by any existing test.

Should I remove the function, the tests and inline the expression? Then my change won't be tested. : )

@nukeop
Copy link
Owner

nukeop commented Feb 19, 2024

Ok, I finished my review. In general, I appreciate that you tested everything very comprehensively.

@sferra sferra requested a review from nukeop February 19, 2024 18:31
@sferra
Copy link
Contributor Author

sferra commented Feb 19, 2024

Side note:

I just noticed that when using the Bandcamp metadata provider, the UI doesn't display proper images for similar artists. This is because there's no logic for fetching artist images from Spotify, like the Discogs metadata provider does. If this PR gets approved, afterwards it would be possible to address this issue by extracting and reusing the current implementation for fetching artist images for the Bandcamp metadata provider.

@nukeop nukeop merged commit 98529a0 into nukeop:master Feb 24, 2024
9 checks passed
nukeop added a commit that referenced this pull request Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants