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

feat(album_repository.go): add kodi-style album playcount option - #1032 #2803

Merged
merged 6 commits into from Apr 27, 2024

Conversation

vvdveen
Copy link
Contributor

@vvdveen vvdveen commented Jan 21, 2024

Closes 1032.

Description

Adds a new configuration option AlbumPlaycountMode. When set to "kodi", album play count will be computed by dividing the total number of plays of all tracks on the album by the number of tracks. This is further discussed in
2711.

I decided to make this option a string, to allow for other approaches / algorithms / modes to be added in the future.

Changes

  • Adds AlbumPlaycountMode to conf/configuration.go and cmd/root.go. Default value is "absolute" meaning album playcount will be the sum of all individual track counts (current behavior).
  • Added hook functionality to persistence/album_repository.go. When converting a dbAlbum to a model, any installed hooks will be invoked on the album.
  • If AlbumPlaycountMode = "kodi", a hook will be installed that will update the playcount according the discussion and issue above.



Signed-off-by: Victor van der Veen <vvdveen@gmail.com>
@dweymouth
Copy link
Contributor

I would recommend a more proper descriptive name for the "kodi" mode such as "normalized"

@deluan
Copy link
Member

deluan commented Jan 22, 2024

Thanks for this. I agree with @dweymouth, we should make the name more descriptive and also not reference the competitor ;)

I'll review it soon, and give you feedback on this.

Signed-off-by: Victor van der Veen <vvdveen@gmail.com>
@vvdveen
Copy link
Contributor Author

vvdveen commented Feb 18, 2024

Just found the time to make those changes and fix formatting. I see my branch is out-of-date with the base branch though. Let me know if I must merge and try again.
I agree the feature requires better documentation but I don't think cmd/root.go is the right place.

Copy link

Download the artifacts for this pull request:

@deluan
Copy link
Member

deluan commented Feb 18, 2024

I agree the feature requires better documentation but I don't think cmd/root.go is the right place.

Yes, this documentation should go to https://www.navidrome.org/docs/usage/configuration-options/#advanced-configuration

Copy link
Member

@deluan deluan left a comment

Choose a reason for hiding this comment

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

LGTM, just fixed some small nitpicks.

Can you please add the new AlbumPlayCountMode config option to the website?

Thanks for the contribution!

@deluan deluan merged commit ef91362 into navidrome:master Apr 27, 2024
5 checks passed
deluan added a commit that referenced this pull request Apr 27, 2024
Closes #1032

* feat(album_repository.go): add kodi-style album playcount option - #1032

Signed-off-by: Victor van der Veen <vvdveen@gmail.com>

* fix format issue and remove reference to kodi (now normalized)

Signed-off-by: Victor van der Veen <vvdveen@gmail.com>

* reduced complexity but added rounding

Signed-off-by: Victor van der Veen <vvdveen@gmail.com>

* Use constants for AlbumPlayCountMode values

---------

Signed-off-by: Victor van der Veen <vvdveen@gmail.com>
Co-authored-by: Deluan <deluan@navidrome.org>
@vvdveen vvdveen deleted the normalise-album-playcount/1032 branch April 27, 2024 20:16
@vvdveen vvdveen restored the normalise-album-playcount/1032 branch April 27, 2024 20:16
@vvdveen vvdveen deleted the normalise-album-playcount/1032 branch April 27, 2024 20:16
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.

Normalise album playcount sorting by amount of tracks
3 participants