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

Add Dandiset star functionality with UI components #2123

Merged
merged 32 commits into from
Feb 5, 2025
Merged

Add Dandiset star functionality with UI components #2123

merged 32 commits into from
Feb 5, 2025

Conversation

bendichter
Copy link
Member

@bendichter bendichter commented Dec 26, 2024

fix #1119

Feature developed with Cursor

  • Introduced DandisetStar model and admin interface for managing starred Dandisets.
  • Implemented star/unstar actions in the DandisetViewSet and corresponding API endpoints.
  • Added star count and starred status to DandisetSerializer.
  • Created StarButton component for toggling star status in the UI.
  • Developed StarredDandisetsView to display Dandisets starred by the user.
  • Updated DandisetList and DandisetLandingView to include star functionality.
  • Enhanced DandisetFilterBackend to support ordering by star count.
  • Update existing tests and add new tests
  • Add package-lock.json to ignore list for spell check

I haven't been able to log in on my dev server so I can't test that behavior, but the unlogged in web UI and the admin interface appear to work as expected

@bendichter bendichter marked this pull request as draft December 26, 2024 16:50
Copy link
Member

@waxlamp waxlamp left a comment

Choose a reason for hiding this comment

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

Very interesting!

I'm a dinosaur who's not ready to trust AI-generated code just yet, so I'll want to get careful reviews from @jjnesbitt and @mvandenburgh (both to identify problems with the code, and so we have team members with a mental model of how it works) before merging. Furthermore, I think this will benefit from some enhancements (like using a service layer to manage stars), as well as some minor stuff that I can push fixes for myself. Finally, I would like for @jtomeck to help out with the frontend design here as well.

Thanks @bendichter for kicking this feature off!

web/package-lock.json Outdated Show resolved Hide resolved
web/yarn.lock Outdated Show resolved Hide resolved
@bendichter
Copy link
Member Author

@waxlamp yes, I mentioned Cursor because I agree that this will need careful eyes on it before integrating. But looking at the changes the majority of them seem straightforward

.pre-commit-config.yaml Outdated Show resolved Hide resolved
@bendichter
Copy link
Member Author

ok yeah the npm-related issues are my fault. I am used to installing with npm and having large automatically generated files as a result of that. I'll make sure to use yarn in the future.

@bendichter bendichter marked this pull request as ready for review December 27, 2024 01:23
@bendichter
Copy link
Member Author

I don't know what to do about the remaining CI check failures

Copy link
Member

@jjnesbitt jjnesbitt left a comment

Choose a reason for hiding this comment

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

Thanks for the work, @bendichter. I've done a first pass of this PR and identified some necessary changes, but nonetheless it's great to have the outline of this feature out of the way.

I'd be happy to address some of these changes myself, if that makes more sense. I'll still leave the comments either way.

dandiapi/api/services/dandiset/__init__.py Outdated Show resolved Hide resolved
dandiapi/api/services/dandiset/__init__.py Outdated Show resolved Hide resolved
dandiapi/api/views/dandiset.py Outdated Show resolved Hide resolved
dandiapi/api/views/dandiset.py Outdated Show resolved Hide resolved
dandiapi/api/views/serializers.py Show resolved Hide resolved
web/yarn.lock Outdated Show resolved Hide resolved
web/src/components/StarButton.vue Outdated Show resolved Hide resolved
web/src/router.ts Outdated Show resolved Hide resolved
@bendichter
Copy link
Member Author

bendichter commented Dec 29, 2024

@jjnesbitt thanks for the prompt and thorough review. I can confirm that I can replicate those UI bugs. I might have time to address them myself but feel free to take this over if you have the bandwidth to do so.

@jjnesbitt
Copy link
Member

jjnesbitt commented Dec 30, 2024

@jjnesbitt thanks for the prompt and thorough review. I can confirm that I can replicate those UI bugs. I might have time to address them myself but feel free to take this over if you have the bandwidth to do so.

I think I have the bandwidth, so today I can make a pass at changing someone of the things I mentioned.

@jjnesbitt jjnesbitt force-pushed the stars branch 4 times, most recently from c2b200c to 0d1aace Compare December 31, 2024 19:14
Copy link
Member

@mvandenburgh mvandenburgh left a comment

Choose a reason for hiding this comment

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

We'll also need to add audit events for starring/unstarring a dandiset.

@jjnesbitt
Copy link
Member

We'll also need to add audit events for starring/unstarring a dandiset.

For posterity: We met offline and agreed to exclude dandiset stars from audit events.

- Introduced DandisetStar model and admin interface for managing starred Dandisets.
- Implemented star/unstar actions in the DandisetViewSet and corresponding API endpoints.
- Added star count and starred status to DandisetSerializer.
- Created StarButton component for toggling star status in the UI.
- Developed StarredDandisetsView to display Dandisets starred by the user.
- Updated DandisetList and DandisetLandingView to include star functionality.
- Enhanced DandisetFilterBackend to support ordering by star count.
- Updated test cases in test_dandiset.py and test_version.py to include 'star_count' and 'is_starred' fields in the expected responses.
- Ensured consistency across various test scenarios for Dandiset and Version APIs regarding star functionality.
@jjnesbitt jjnesbitt requested a review from waxlamp January 28, 2025 20:30
Copy link
Member

@mvandenburgh mvandenburgh left a comment

Choose a reason for hiding this comment

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

@jjnesbitt just one point about the failure conditions for starring/unstarring. I think you could make an argument for either way (i.e., starring/unstarring is idempotent and always returns a 2xx as it is now, vs. verifying validity of the request and possibly rejecting it with a 4xx), any thoughts?

dandiapi/api/services/dandiset/__init__.py Show resolved Hide resolved
dandiapi/api/services/dandiset/__init__.py Show resolved Hide resolved
@jjnesbitt
Copy link
Member

@jjnesbitt just one point about the failure conditions for starring/unstarring. I think you could make an argument for either way (i.e., starring/unstarring is idempotent and always returns a 2xx as it is now, vs. verifying validity of the request and possibly rejecting it with a 4xx), any thoughts?

IMO the star/unstar operation should be idempotent. Raising an error in this case doesn't really provide us with much benefit.

It can actually lead to an undesirable outcome in the following situation:

  1. User has a dandiset open in two tabs for some reason.
  2. In the first tab they star the dandiset, showing it reflected as being starred.
  3. Later, in the second tab, they see it isn't starred for some reason, and hit star again. Since the front-end is out of sync with the back-end, that would call /star again, and raise an exception.

This is unnecessarily confusing to the user with no real upside. It's not like the user can do anything, and we couldn't really do anything either, except for try to prevent that situation from occurring in the first place.

Copy link
Member

@waxlamp waxlamp left a comment

Choose a reason for hiding this comment

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

This looks great, and I don't wish to hold up merge-and-deploy any longer, but I did have some questions and some minor suggestions in case they're useful.

dandiapi/api/tests/test_dandiset.py Outdated Show resolved Hide resolved
dandiapi/api/views/dandiset.py Outdated Show resolved Hide resolved
dandiapi/api/services/dandiset/__init__.py Show resolved Hide resolved
dandiapi/api/models/dandiset.py Outdated Show resolved Hide resolved
Copy link
Member

@waxlamp waxlamp left a comment

Choose a reason for hiding this comment

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

I have a remaining suggestion about unifiying two functions, but I'm leaving that to your discretion -- this looks ready to go.

dandiapi/api/views/dandiset.py Outdated Show resolved Hide resolved
@jjnesbitt jjnesbitt added patch Increment the patch version when merged release Create a release when this pr is merged labels Feb 5, 2025
@jjnesbitt jjnesbitt merged commit 6e31d43 into master Feb 5, 2025
11 checks passed
@jjnesbitt jjnesbitt deleted the stars branch February 5, 2025 20:46
@dandibot
Copy link
Member

dandibot commented Feb 5, 2025

🚀 PR was released in v0.4.16 🚀

@dandibot dandibot added the released This issue/pull request has been released. label Feb 5, 2025
@kabilar
Copy link
Member

kabilar commented Feb 5, 2025

Great work team. This is a really nice feature. I tested on staging and production, and it is working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHub stars on dandisets
7 participants