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 club diff feature #705

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Add club diff feature #705

wants to merge 8 commits into from

Conversation

Porcupine1
Copy link
Contributor

@Porcupine1 Porcupine1 commented Jun 20, 2024

This pull request introduces a new feature aimed at enhancing the admin experience by providing a concise display of changes made to a club's information when it is re-submitted for approval. This feature addresses the current challenge where admins have to manually compare and identify changes by reviewing the entire club page, which is not ideal.

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.19%. Comparing base (8561edc) to head (1724ec7).
Report is 65 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #705      +/-   ##
==========================================
+ Coverage   71.10%   71.19%   +0.09%     
==========================================
  Files          31       31              
  Lines        6824     6842      +18     
==========================================
+ Hits         4852     4871      +19     
+ Misses       1972     1971       -1     

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

backend/clubs/models.py Outdated Show resolved Hide resolved
Copy link
Member

@aviupadhyayula aviupadhyayula left a comment

Choose a reason for hiding this comment

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

Great work Thomas, thanks for picking this up. Left a couple comments. We'll need thorough unit tests for this, but should be good to go after minor fixes & adding tests.

backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
backend/clubs/models.py Outdated Show resolved Hide resolved
):
return {}

diff = latest_version.diff_against(latest_approved_version)
Copy link
Member

Choose a reason for hiding this comment

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

If we're only reporting name, description, and image changes, do we need to diff every field? Hint

Copy link
Member

Choose a reason for hiding this comment

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

Yep, in retrospect I'm not sure if this line is strictly necessary in the first place if we're computing diffs on the frontend (as discussed) anyways. We could compute on the backend but it would require more detailed serialization and not necessarily be much more performant at this scale.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, agreed. I'm sure React has some great diff libraries. I think it'd be cleaner to expose something that fetches the most recently approved version of a club, and we can do diffing on the frontend.

I'm also not sure where the pending_clubs endpoint would be used. We already know which clubs we want to diff (e.g. the ones in the approval queue), and I can't see where we'd use this outside of the queue.

@Porcupine1 it'd be helpful to iron out the details with Julian further.

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 remember we discussed that initially we were just the calling the clubs viewset list function with the approved = false and active = true query/search params. I added pending_clubs because we are now returning pending clubs data

# if this is the first time the club is being approved
if not latest_approved_version:
return {
self.code: {
Copy link
Member

Choose a reason for hiding this comment

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

would prefer to add the club code to the response in the view instead of this helper

Copy link
Contributor Author

@Porcupine1 Porcupine1 Sep 1, 2024

Choose a reason for hiding this comment

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

I think if we make the route instance-specific, we won't require the club code, right? With this new implementation, it looks like the approval queue list will remain as is, only that the link to a club in the queue is to /api/clubs/<code>/diff/

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we'll point to a new page for clubs in the queue (e.g. right now clicking on a club in the queue goes to /api/clubs/<code>).

Instead, the idea is to expose an endpoint /diff that returns some historical comparison (either the last approved version, or the diffs themselves). We'll then add a param when an admin clicks on a club in the queue (e.g. /api/clubs/<code>?review=True) that triggers some frontend logic. The frontend logic is what's going to call /api/clubs/<code>/diff and display the results in some fashion.

@julianweng @rm03 let me know if that's what we were thinking here.

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 see, that makes sense. I was actually thinking that there would be code repetition (with /api/clubs/<code> route) if implemented the way I described it earlier

backend/clubs/views.py Show resolved Hide resolved
@Porcupine1 Porcupine1 requested a review from rm03 October 13, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants