-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(model): add Rated At field - #4653 #4660
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
Signed-off-by: zacaj <zacaj@zacaj.com>
Summary of ChangesHello @zacaj, 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 introduces the ability to track and display the exact time a user rates a song. It involves a database migration to add a new timestamp column, updates to the data model and persistence layer to store this information, and front-end changes to visualize these timestamps as tooltips in the user interface, enhancing the user's ability to see when they last interacted with a song's rating or 'loved' status. Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
| ALTER TABLE annotation ADD COLUMN rated_at datetime; | ||
| -- +goose StatementEnd | ||
|
|
||
| -- +goose Down |
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.
note- didn't add any Down to remove the column since it shouldn't cause any issues if it's still there while code is downgraded and didn't want to risk losing data if a db somehow got migrated down and then back up again
| @@ -0,0 +1,7 @@ | |||
| -- +goose Up | |||
| -- +goose StatementBegin | |||
| ALTER TABLE annotation ADD COLUMN rated_at datetime; | |||
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.
Column is nullable for backwards compatibility- if you prefer to default to the current timestamp during migration in order to keep the column non-nullable lmk.
ui/src/common/RatingField.jsx
Outdated
| <span | ||
| onClick={(e) => stopPropagation(e)} | ||
| title={ | ||
| record.ratedAt ? new Date(record.ratedAt).toLocaleString() : undefined |
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.
should this have any of the logic in DateField.jsx regarding ignoring '0001-01-01T00:00:00Z' or passing in a locale/etc to toLocaleString() ?
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.
Yes, it should ignore empty dates (0001-01-01T00:00:00Z). We don't need to pass a locate unless you add tests for it.
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.
added check for empty dates to each component
is there any like, util file that'd be a good place to maybe pull out the date check (and/or formatting) logic for easier consistency?
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.
We do have a ui/src/utils folder for this type of utility functions
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.
ah, I was looking for a file called utils, not a folder, doh.
Would you like me to move all three cases of the empty date check here, probably in validations.js, as part of this PR?
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.
added
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 introduces a rated_at field to track when songs are rated, with changes across the database, backend, and UI. The implementation is mostly solid, but I have a few suggestions. My main feedback concerns the database migration, which is missing its Down implementation for rollbacks. I also suggest refining the logic for when rated_at is set to improve data semantics and the user experience of the new tooltips. A similar point is raised for the starred_at tooltip for consistency.
Summary of ChangesHello @zacaj, 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 introduces a new feature that tracks and displays the exact time a song was rated. It adds a Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
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 introduces a rated_at timestamp to track when a song's rating is set. The changes are well-integrated across the database, backend, and frontend, including a new tooltip to display this information. For consistency, a similar tooltip has been added for the 'starred' timestamp. The overall implementation is solid, but I have one important suggestion regarding the database migration to ensure it can be safely rolled back.
deluan
left a comment
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.
LGTM, but check my comment below. I know the annotations feature does not have any tests atm, so it is fine to not have added them. Unless you feel compelled to write some tests for it :)
ui/src/common/RatingField.jsx
Outdated
| <span | ||
| onClick={(e) => stopPropagation(e)} | ||
| title={ | ||
| record.ratedAt ? new Date(record.ratedAt).toLocaleString() : undefined |
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.
Yes, it should ignore empty dates (0001-01-01T00:00:00Z). We don't need to pass a locate unless you add tests for it.
Signed-off-by: zacaj <zacaj@zacaj.com>
Added comprehensive tests for isDateSet and urlValidate functions in ui/src/utils/validations.test.js covering falsy values, Go zero date handling, valid date strings, Date objects, and edge cases. Added rated_at sort mapping to album, artist, and mediafile repositories, following the same pattern as starred_at (sorting by rating first, then by timestamp). This enables proper sorting by rating date in the UI.
|
Thanks! Can you also create a PR for the documentation website for the new Smart Playlist field? Thanks! |
|
Description
Adds a
rated_atcolumn to theannotationtable to record when a song was rated.Adds a display of the rating date/time to the
<RatingField>component viatitletooltip just to make it a bit more useful. Since I was in there I also added a similar tooltip to the Star/Loved component for consistency- lmk if you'd prefer one/both of these removed or in their own PRSome thoughts/questions while coding this:
Related Issues
Fixes #4653
Type of Change
Checklist
Please review and check all that apply:
starred_at), so assuming this falls below the 'worth testing' thresholdHow to Test
Screenshots / Demos (if applicable)
Additional Notes
I coded this in a dev container; not sure how much those are used/tested but I had two issues which may be problems with the dev container or may just be something with my computer:
make setup, I couldn't compile the taglib wrapper .cpp file due to it not finding the header files. Adding-I /usr/include/taglibto the#cgo linuxline fixed this.configuration_test.go(and thus, the pre-push hook) failed because theND_MUSICFOLDERenv var in thedevcontainer.jsonfile was overriding themusicFolderfield being tested by the config files. In the end I worked around this by disabling the env var functionality completely but this is probably a bug with the test not using isolated environment vars? or would be good to at least change the test to use a lesser-used config setting instead of one that is used universallyjavascript, but not for .jsx files, so by default it wasn't formatting most of my changes at all until I manually rannpm run prettier(also, the instructions frommake lintalldon't mention that you need to run it inside theui/folder).