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

feat(dashboards): add new endpoint for favourite dashboards #81438

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

harshithadurai
Copy link
Member

Add new endpoint for favourite dashboards

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 28, 2024
@@ -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,
Copy link
Member Author

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

Copy link

codecov bot commented Nov 28, 2024

❌ 13 Tests Failed:

Tests completed Failed Passed Skipped
23216 13 23203 213
View the top 3 failed tests by shortest run time
tests.sentry.api.endpoints.test_organization_dashboards.OrganizationDashboardsTest::test_get_sortby
Stack Traces | 2.04s run time
#x1B[1m#x1B[.../api/endpoints/test_organization_dashboards.py#x1B[0m:113: in test_get_sortby
    values = [row[sorting.strip("-")] for row in response.data if row["dateCreated"]]
#x1B[1m#x1B[31mE   TypeError: 'NoneType' object is not subscriptable#x1B[0m
tests.sentry.api.endpoints.test_organization_dashboards.OrganizationDashboardsTest::test_widget_preview_field_contains_display_type_and_layout
Stack Traces | 2.05s run time
#x1B[1m#x1B[.../api/endpoints/test_organization_dashboards.py#x1B[0m:861: in test_widget_preview_field_contains_display_type_and_layout
    assert "widgetPreview" in dashboard_data
#x1B[1m#x1B[31mE   TypeError: argument of type 'NoneType' is not iterable#x1B[0m
tests.sentry.api.endpoints.test_organization_dashboards.OrganizationDashboardsTest::test_get_query
Stack Traces | 2.05s run time
#x1B[1m#x1B[.../api/endpoints/test_organization_dashboards.py#x1B[0m:89: in test_get_query
    self.assert_equal_dashboards(self.dashboard, response.data[0])
#x1B[1m#x1B[.../api/endpoints/test_organization_dashboards.py#x1B[0m:39: in assert_equal_dashboards
    assert data["id"] == str(dashboard.id)
#x1B[1m#x1B[31mE   TypeError: 'NoneType' object is not subscriptable#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Comment on lines +234 to +239
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)
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant