-
Notifications
You must be signed in to change notification settings - Fork 134
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
User per-role cache key for the organization_profile_viewset #2665
User per-role cache key for the organization_profile_viewset #2665
Conversation
Also, invalidate cache when user x organization permissions are updated Co-authored-by: Kelvin Muchiri <[email protected]>
b062185
to
cebcded
Compare
onadata/apps/api/tasks.py
Outdated
@@ -36,6 +38,14 @@ | |||
User = get_user_model() | |||
|
|||
|
|||
def invalidate_organization_cache(org_username): |
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.
Can we move this to logger_tools
?
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've moved it to cache_tools
instead
cache.set(f"{ORG_PROFILE_CACHE}{username}{request.user.username}", organization) | ||
organization_profile = OrganizationProfile.objects.get(user__username=username) | ||
cache_key = get_cache_key(request.user, organization_profile) | ||
cache.set(cache_key, 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.
Should we use set_cache_for_org
here?
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.
@FrankApiyo I've just realized set_cache_for_org
is in test_tasks
and not in this file
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
serializer.save() | ||
|
||
data = OrganizationSerializer( |
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 use instead self.get_serializer_class
09b94e3
to
332b9c0
Compare
332b9c0
to
ba44d71
Compare
Changes / Features implemented
Steps taken to verify this change does what is intended
Side effects of implementing this change
N/A
Before submitting this PR for review, please make sure you have:
Closes #2672