-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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(dashboards): add new endpoint for favourite dashboards #81438
base: master
Are you sure you want to change the base?
feat(dashboards): add new endpoint for favourite dashboards #81438
Conversation
@@ -252,6 +254,7 @@ def serialize(self, obj, attrs, user, **kwargs) -> DashboardListResponse: | |||
"widgetDisplay": attrs.get("widget_display", []), | |||
"widgetPreview": attrs.get("widget_preview", []), | |||
"permissions": serialize(obj.permissions) if hasattr(obj, "permissions") else None, | |||
"isFavourited": user.id in obj.favourited_by, |
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 to self: what happens when favourited_by
doesn't exist in dashboard obj
❌ 13 Tests Failed:
View the top 3 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
if is_favourited and request.user.id not in current_favourites: | ||
current_favourites.add(request.user.id) # Add user to the set | ||
elif not is_favourited and request.user.id in current_favourites: | ||
current_favourites.remove(request.user.id) | ||
else: | ||
Response(status=204) |
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.
conditions:
not fav, not in list -> do nothing
not fav, in lits -> remove frm list
in fav, in list -> do nothing
in fav, not in list -> add to list
Add new endpoint for favourite dashboards