Skip to content

Conversation

@MichaelSun48
Copy link
Contributor

Creates the PUT /group-search-views/:viewId, which updates a single view.

This endpoint requires aa fully verbose view as its input — that is, all filter values must be populated, even if they have not been changed.

In addition to the standard filter params, two non-required params are available to include:

  1. visibility: {"owner", "organization"}: Whether or not to change the visibility of the view. Only org members with team:admin, org:admin, or org:owner permissions are allowed to change the visibility of a view from "owner" to "organization"
  2. starred: bool : Whether or not to add or remove view from the starred list.

@MichaelSun48 MichaelSun48 requested a review from a team as a code owner March 27, 2025 17:03
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 27, 2025
Comment on lines 84 to 85
if "starred" in validated_data:
if validated_data["starred"]:
Copy link
Member

Choose a reason for hiding this comment

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

aren't these two if's doing the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

starred isn't a required query param, so the first one checks if it exists, and the second one checks if its true.

Copy link
Member

Choose a reason for hiding this comment

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

in what case would we not pass starred in? i thought we had to pass the whole view in, so in the case where it's already starred and then we don't pass starred in, we keep it starred?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This tangentially answers your question, but I think it might make sense to just remove this query param entirely since its redundant with the POST /group-search-view-starred/ endpoint, and I'm not sure if there will be an entrypoint to editing the filter params AND the starred status in the same flow

from sentry.api.serializers.base import serialize
from sentry.api.serializers.models.groupsearchview import GroupSearchViewSerializer
from sentry.api.serializers.rest_framework.groupsearchview import GroupSearchViewDetailsPutValidator
from sentry.issues.endpoints.organization_group_search_views import pick_default_project
Copy link
Member

Choose a reason for hiding this comment

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

it's not ideal to import a helper function from one endpoint to another. maybe pick_default_project could go either into the org member model, or group search view model? could also consider making a utils or "usecase" file for gsvs in the issues folder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I thought about this and I'm not exactly sure where the best place to put this is... I'm hesitant to add it to a foundational model (like OrgMember or Project) since that would imply that this "default project" logic should be used across the product, which makes me a little hesitant. On the other hand, putting it on the GroupSearchView model is a little weird since that logic doesn't even touch the GroupSearchView table. A utils folder might be the best place for it for now...

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'm going to include this change in a separate PR to improve file structure, since there are other relevant changes I'd want to include in there (like moving things to an Issues folder, per your suggestion in a previous PR)

Copy link
Member

@armenzg armenzg left a comment

Choose a reason for hiding this comment

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

I did not get a chance to look at the tests before my next meeting.


validated_data = serializer.validated_data

view.name = validated_data["name"]
Copy link
Member

Choose a reason for hiding this comment

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

You may be able to add a method to view to read the parameters (e.g. view.read_data(validated_data)) or even store it as view.data = validated_data.

@MichaelSun48 MichaelSun48 merged commit 7f80c90 into master Mar 31, 2025
48 checks passed
@MichaelSun48 MichaelSun48 deleted the msun/sharedViews/addPutEndpoint branch March 31, 2025 17:09
andrewshie-sentry pushed a commit that referenced this pull request Mar 31, 2025
…for updating a view (#88111)

Creates the `PUT` `/group-search-views/:viewId`, which updates a single
view.

This endpoint requires aa fully verbose view as its input — that is, all
filter values must be populated, even if they have not been changed.

In addition to the standard filter params, two non-required params are
available to include:

1. `visibility: {"owner", "organization"}`: Whether or not to change the
visibility of the view. Only org members with `team:admin`, `org:admin`,
or `org:owner` permissions are allowed to change the visibility of a
view from "owner" to "organization"
2. `starred: bool` : Whether or not to add or remove view from the
starred list.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants