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

Cache admins and collaborators for permissions #5472

Merged

Conversation

chenriksson
Copy link
Member

Issue #5461, optimization 2.

Caches and separates admin/collaborators lookups for current user during permissions checks so duplicate checks don't hit the DB.

Originally saw response go from 37.8s -> 35.1s, but now seeing it go from 59.1s -> 42.5s

@@ -109,7 +109,7 @@ public class UserService : IUserService
if (membership.IsAdmin != isAdmin)
{
// block removal of last admin
if (membership.IsAdmin && organization.Members.Count(m => m.IsAdmin) == 1)
if (membership.IsAdmin && organization.Administrators.Count() == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

rganization.Administrators.Count() == 1 [](start = 43, length = 39)

nit: use Any()

Copy link
Member Author

Choose a reason for hiding this comment

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

The check is to see if the last admin is being removed, so I need to check for exactly 1 not >= 1

Copy link
Contributor

@skofman1 skofman1 left a comment

Choose a reason for hiding this comment

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

:shipit:

@chenriksson chenriksson force-pushed the chenriks-perf-managepackages branch 2 times, most recently from 5b0bacd to 0f557ab Compare February 15, 2018 20:34
@chenriksson chenriksson force-pushed the chenriks-perf-managepackages2 branch from 4888c2c to a8a7e4b Compare February 15, 2018 21:51
@chenriksson chenriksson merged commit 4a7c642 into chenriks-perf-managepackages Feb 15, 2018
chenriksson added a commit that referenced this pull request Feb 15, 2018
@chenriksson chenriksson deleted the chenriks-perf-managepackages2 branch February 15, 2018 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants