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

Action policy/speedup #858

Merged
merged 15 commits into from
Jan 6, 2025
Merged

Action policy/speedup #858

merged 15 commits into from
Jan 6, 2025

Conversation

deepsidhu85
Copy link
Contributor

@deepsidhu85 deepsidhu85 commented Nov 29, 2024

What does this PR do and why?

Describe in detail what your merge request does and why.

This PR refactors the project namespace, project, and group policies so that the access level is only retrieved once during the initialization which cuts down on the number of queries to the database.

Some benchmarks from accessing the samples page for streptococcus and descendant groups:

http://localhost:3000/-/groups/streptococcus/-/samples

main: Completed 200 OK in 502ms (Views: 370.9ms | ActiveRecord: 57.8ms (80 queries, 31 cached) | GC: 25.4ms)

actionpolicy speedup: Completed 200 OK in 396ms (Views: 267.2ms | ActiveRecord: 52.3ms (60 queries, 11 cached) | GC: 23.5ms)



http://localhost:3000/-/groups/streptococcus/streptococcus-pyogenes/-/samples

main: Completed 200 OK in 427ms (Views: 296.7ms | ActiveRecord: 49.8ms (76 queries, 32 cached) | GC: 20.8ms)

actionpolicy speedup: Completed 200 OK in 426ms (Views: 297.2ms | ActiveRecord: 55.6ms (56 queries, 12 cached) | GC: 8.0ms)



http://localhost:3000/streptococcus/streptococcus-pyogenes/streptococcus-pyogenes-m92/outbreak-2023/-/samples

main: Completed 200 OK in 1526ms (Views: 984.4ms | ActiveRecord: 66.6ms (97 queries, 84 cached) | GC: 332.5ms)

actionpolicy speedup: Completed 200 OK in 191ms (Views: 129.4ms | ActiveRecord: 19.8ms (22 queries, 9 cached) | GC: 2.5ms)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

This comment has been minimized.

This comment has been minimized.

@deepsidhu85 deepsidhu85 self-assigned this Dec 4, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@deepsidhu85 deepsidhu85 force-pushed the action_policy/speedup branch from df838f8 to a51b153 Compare December 13, 2024 15:41

This comment has been minimized.

@deepsidhu85 deepsidhu85 force-pushed the action_policy/speedup branch from a51b153 to 82df800 Compare December 20, 2024 16:33

This comment has been minimized.

This comment has been minimized.

@deepsidhu85 deepsidhu85 requested a review from ericenns December 20, 2024 22:21
@deepsidhu85 deepsidhu85 marked this pull request as ready for review December 20, 2024 22:21
Copy link
Member

@ericenns ericenns left a comment

Choose a reason for hiding this comment

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

This is looking good, I just found a couple issues and then a couple suggestions.

app/policies/group_policy.rb Show resolved Hide resolved
app/policies/project_policy.rb Outdated Show resolved Hide resolved
app/policies/project_policy.rb Outdated Show resolved Hide resolved
app/policies/project_policy.rb Outdated Show resolved Hide resolved
ericenns and others added 13 commits January 6, 2025 09:41
…es to get project with namespace and parent namespace for routing
…itialization and use that to determine permissions
…nding on if the params includes group links or not, and to set if the token is active for an uploader.
… to get the effective access level on initialize
…ctive_access_level method which will get the access level if group links are included or not. Reverted changes to views for passing in include_group_links in the context
…e. Also updated project policy method for transfer sample into project to use the set effective level
…red. Removed commented out code from policies
…thod directly which fixed the previous error of undefined method details
@deepsidhu85 deepsidhu85 force-pushed the action_policy/speedup branch from c9613bc to ea98b5a Compare January 6, 2025 15:41

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@ericenns ericenns left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@ericenns ericenns merged commit 08505f0 into main Jan 6, 2025
4 checks passed
@ericenns ericenns deleted the action_policy/speedup branch January 6, 2025 19:46
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.

2 participants