-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(api): Added Project ID in Body Support for Couple APIs #74371
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
Conversation
), | ||
filter_params["end"] if filter_params["end"] else datetime.utcnow(), |
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.
auto formatted
@@ -9,16 +9,22 @@ | |||
|
|||
@extend_schema_field(field=OpenApiTypes.STR) | |||
class ProjectField(serializers.Field): | |||
def __init__(self, scope="project:write"): | |||
def __init__(self, scope="project:write", id_allowed=False): |
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.
we should eventually support id lookup everywhere this field is used, but didn't want to pollute this PR with the implications of that
for slug in result["projects"]: | ||
if slug not in allowed_projects: |
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.
I think this logic would have to be updated to reflect the new mapping
@@ -464,12 +466,15 @@ def post(self, request: Request, organization) -> Response: | |||
result = serializer.validated_data | |||
scope.set_tag("version", result["version"]) | |||
|
|||
allowed_projects = {p.slug: p for p in self.get_projects(request, organization)} | |||
projects_from_request = self.get_projects(request, organization) |
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.
I took a look at get_projects
but I couldn't figure out how this would work when the projects
is a list of slugs and IDs. Did you take a look at the function?
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.
discussed offline
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #74371 +/- ##
=======================================
Coverage 78.13% 78.13%
=======================================
Files 6670 6670
Lines 298568 298572 +4
Branches 51375 51376 +1
=======================================
+ Hits 233287 233298 +11
+ Misses 59016 59014 -2
+ Partials 6265 6260 -5
|
allowed_projects = {project.slug: project for project in projects_from_request} | ||
allowed_projects.update({project.id: project for project in projects_from_request}) |
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.
two loops smh
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.
not optimal enough
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.
smh i had something better before, what do u want me to do 😭
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.
how about:
allowed_projects = {}
for project in projects_from_request:
allowed_projects[project.slug] = project
allowed_projects[project.id] = project
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.
nice and simple
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.
nothing fancy
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.
traditional loops 🙄 , looks good to me
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.
kids these days 👴
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
I am working on getting all the commands in our Sentry CLI to support Ids as well as Slugs. rough spec
We have already gone through the effort of supporting ids and slugs in path parameters of all the APIs in our codebase. There are some endpoints that the CLI uses that pass in project slugs as body parameters, so we need to support Ids for those as well.