-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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(ACI): Detector details PUT endpoint #84098
base: master
Are you sure you want to change the base?
Conversation
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
394cdec
to
4330776
Compare
3137949
to
ec4b7fe
Compare
22b212a
to
c9992a3
Compare
c9992a3
to
2ab2d9c
Compare
449820d
to
12075bf
Compare
12075bf
to
90424c8
Compare
group_type = None | ||
detector_group_type = detector.group_type | ||
|
||
if detector_group_type: | ||
group_type = request.data.get("detector_type") or detector_group_type.slug | ||
|
||
if not group_type: | ||
return Response(status=status.HTTP_400_BAD_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.
this is all for annoying typing reasons - if detector.group_type
is None
we can't get the slug
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.
should we raise an exception if it's None
in Detector.group_type
so we can assume the return type is GroupType
?
group_type = None | ||
detector_group_type = detector.group_type | ||
|
||
if detector_group_type: | ||
group_type = request.data.get("detector_type") or detector_group_type.slug | ||
|
||
if not group_type: | ||
return Response(status=status.HTTP_400_BAD_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.
should we raise an exception if it's None
in Detector.group_type
so we can assume the return type is GroupType
?
raise serializers.ValidationError("DataConditionGroup not found, can't update") | ||
# TODO make one if it doesn't exist and data is passed? | ||
|
||
for data_condition in data_conditions: |
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.
would it be better to collect all the data conditions for the data condition group, delete them if they exist, and create new data conditions? we could use bulk_delete
and bulk_create
that way instead of one by one (fewer db hits) 🤔
def update_data_source(self, instance, data_source): | ||
try: | ||
source_instance = DataSource.objects.get(detector=instance) | ||
except DataSource.DoesNotExist: |
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.
does the data source need to be created if you add it to an existing detector?
def update(self, instance, validated_data): | ||
instance.name = validated_data.get("name", instance.name) | ||
instance.type = validated_data.get("detector_type", instance.group_type).slug | ||
condition_group = validated_data.pop("condition_group") |
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.
nit: is there a reason this is pop
instead of get
?
Create a PUT endpoint for detector details.
Addresses https://getsentry.atlassian.net/browse/ACI-114