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

fix: Add rolling users validation for oncall shift API #5050

Merged
merged 2 commits into from
Sep 20, 2024

Conversation

ravishankar15
Copy link
Contributor

@ravishankar15 ravishankar15 commented Sep 20, 2024

What this PR does

Adds validation for rolling users param in the shift api

Which issue(s) this PR closes

Closes 5041

Checklist

  • Unit, integration, and e2e (if applicable) tests updated
  • Documentation added (or pr:no public docs PR label added if not required)
  • Added the relevant release notes label (see labels prefixed w/ release:). These labels dictate how your PR will
    show up in the autogenerated release notes.

@ravishankar15 ravishankar15 requested a review from a team September 20, 2024 11:16
@ravishankar15 ravishankar15 force-pushed the rolling-users-validation branch from 3f6219b to a74bb03 Compare September 20, 2024 11:16
Copy link
Contributor

@joeyorlando joeyorlando left a comment

Choose a reason for hiding this comment

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

LGTM 👍 thanks for patch @ravishankar15! 🙂

@joeyorlando joeyorlando added pr:no public docs Added to a PR that does not require public documentation updates release:patch PR will be added to "Other Changes" section of release notes labels Sep 20, 2024
Copy link
Contributor

@matiasb matiasb left a comment

Choose a reason for hiding this comment

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

Makes sense to me 👍
Minor suggestions added.

if not self.db_verification:
return users

for d in data:
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this check be equivalent to do something like
len(set(data)) == users.count()
(ie. make sure we have a user per provided ppk)? I guess you could do a set difference to get the missing users too?

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 have Made the changes accordingly

@@ -29,7 +29,7 @@ class OnCallShiftSerializer(EagerLoadingMixin, serializers.ModelSerializer):
allow_null=True,
required=False,
child=UsersFilteredByOrganizationField(
queryset=User.objects, required=False, allow_null=True
queryset=User.objects, db_verification=True, required=False, allow_null=True
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest a different name for the param, based on my understanding of the check (see also the comment below), eg. require_all_exist?

@matiasb matiasb added this pull request to the merge queue Sep 20, 2024
Merged via the queue into grafana:dev with commit 1f209cd Sep 20, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates release:patch PR will be added to "Other Changes" section of release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When creating an oncall-shift via the public API, rolling_users is not validated
3 participants