-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: implement RecentlyAddedByModTime support for tracks (#4046) #4279
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
Conversation
Fixes #4046 by adding recently_added sort mapping to MediaFileRepository that respects the RecentlyAddedByModTime configuration setting. Previously, this feature only worked for albums, causing inconsistent behavior when clients requested tracks sorted by 'recently added'. Changes include: - Add mediaFileRecentlyAddedSort() function that returns 'updated_at' when RecentlyAddedByModTime=true, 'created_at' otherwise - Add 'recently_added' sort mapping to mediafile repository - Add comprehensive tests to verify both configuration scenarios This ensures consistent sorting behavior between albums and tracks when using the RecentlyAddedByModTime feature.
Modified the createdAt field in the SongList component to include a sortBy attribute set to "recently_added". This change ensures that the media files are displayed in the order they were added, improving the user experience when browsing through recently added items. Signed-off-by: Deluan <deluan@navidrome.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issue #4046 by updating the recently added sorting behavior for tracks, ensuring the system uses the proper timestamp based on configuration.
- Updated SongList.jsx to pass the sort key "recently_added" for the "Date Added" column.
- Added backend support in mediafile_repository.go with a new mediaFileRecentlyAddedSort() function.
- Introduced test cases in mediafile_repository_test.go for both configuration scenarios.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
ui/src/song/SongList.jsx | Updated DateField to sort tracks using "recently_added" sort key. |
persistence/mediafile_repository_test.go | Added tests for sorting behavior with different configuration settings. |
persistence/mediafile_repository.go | Implemented mediaFileRecentlyAddedSort() function to return the correct sort field. |
Comments suppressed due to low confidence (2)
ui/src/song/SongList.jsx:186
- It would be helpful to add an inline comment explaining that the sortBy prop 'recently_added' is used to respect the RecentlyAddedByModTime configuration, especially since the displayed source remains 'createdAt'.
<DateField source="createdAt" sortBy="recently_added" showTime />
persistence/mediafile_repository_test.go:167
- Consider enhancing the tests to verify not just that results are returned, but that the ordering of the results is correct according to the configuration (i.e., check that the sort order changes between created_at and updated_at based on RecentlyAddedByModTime).
results, err := mr.GetAll(model.QueryOptions{Sort: "recently_added", Order: "desc"})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a long-standing issue where the 'Date Added' sorting for individual tracks did not honor the RecentlyAddedByModTime
server configuration. It introduces the necessary backend logic to allow tracks to be sorted by their modification time when the setting is enabled, and updates the frontend to correctly request this new sorting behavior, providing a consistent and configurable 'recently added' experience across the application.
Highlights
- Track Sorting Logic Enhancement: Implemented a new backend function,
mediaFileRecentlyAddedSort()
, that dynamically determines whether to sort individual tracks by theirupdated_at
(modification time) orcreated_at
timestamp. This decision is based on theRecentlyAddedByModTime
server configuration setting. - Backend Sort Key Integration: Updated the
mediafile
repository to include a newrecently_added
sort mapping. This mapping now leverages the dynamic logic provided bymediaFileRecentlyAddedSort()
to ensure that track sorting respects the configured preference for 'recently added' items. - Frontend UI Alignment: Modified the
SongList.jsx
component in the frontend. The 'Date Added' column now explicitly uses thesortBy="recently_added"
key when requesting data from the backend, ensuring that the user interface correctly reflects the server's configured sorting behavior for tracks. - Comprehensive Test Coverage: Added new, dedicated test cases to
mediafile_repository_test.go
. These tests validate the correct behavior of therecently_added
sort option under both scenarios: whenRecentlyAddedByModTime
is enabled (sorting byupdated_at
) and when it is disabled (sorting bycreated_at
).
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request implements RecentlyAddedByModTime
support for tracks. The changes are well-structured across the backend and frontend. My review includes suggestions to improve the robustness of the SQL query by qualifying column names and to enhance the tests to properly validate the new sorting logic.
Signed-off-by: Deluan <deluan@navidrome.org>
This PR fixes issue #4046 by implementing RecentlyAddedByModTime configuration support for individual tracks/mediafiles.
Problem
The RecentlyAddedByModTime configuration setting only worked for albums, not for individual tracks. When sorting tracks by "Date Added", the system would always use created_at regardless of the configuration setting.
Solution
Backend Changes
mediaFileRecentlyAddedSort()
function to respect the RecentlyAddedByModTime configurationrecently_added
sort mapping to mediafile repository that uses modification time when configuredFrontend Changes
sortBy="recently_added"
for the "Date Added" columnCloses #4046