Query related epics of an epic
Related to #202431 (closed).
Similarly to Issue#related_issues, we need to be able to query all epics related to a given epic.
Requirements
- Check for the user's permissions to read them
We could implement a new method
Ability.epics_readable_by_userthat iterates every epic withreadable_by?(user). Similarly toAbility.issues_readable_by_user.
As with most permission checks, the performance impact is a concern and should be evaluated.
Consider comments in the original discussion by @jprovaznik:
Click to expand
I think the most probable impact is there will be an N+1 issue when checking permission for each of the target epic, but given that this should be a small number (similar as for related issues), I think it's acceptable.
If I try something like this:
DeclarativePolicy.user_scope do Epic.all.preload(:group).select { |epic| Ability.allowed?(user, "read_epic", epic) } end
Then the only N+1 query I hit locally is:
SamlProvider Load (0.2ms) SELECT "saml_providers".* FROM "saml_providers" WHERE "saml_providers"."group_id" = 28 > LIMIT 1 /*application:console,db_config_name:main,line:/ee/app/models/ee/group.rb:202:in `block in root_saml_provider'*/
But there is not much we can do about this one.
- Update the number of blocking epics of an epic when this number changes (see
EE::Issue#update_blocking_issues_count!)
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.