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

Don't load filtered-out parents eagerly on every Object.access #997

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

psrok1
Copy link
Member

@psrok1 psrok1 commented Dec 11, 2024

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)
  • [ ] I've added automated tests for my change (if applicable, optional) (already covered)
  • [ ] I've updated documentation to reflect my change (if applicable) (no changes)

What is the current behaviour?

There is definitely too much magic there that is quite ineffective. When object has lots of parents, every Object.access() that is called in almost every object endpoint will eagerly load all parents and all its tags even if they're not used by the endpoint.

What is the new behaviour?

Replaced eager loading with property accessible_parents that makes a query when requested. It is then called by proper schema fields.

Other functions that are relying on user's view of parents are already using dedicated query instead of object.parents direct relationship access (e.g. search additionally filters out objects using g.auth_user.has_access_to_object)

Test plan

Security checks covered by automated tests. Performed manual check if everything works properly.

Closing issues

@psrok1 psrok1 force-pushed the fix/no-eager-parents branch from b3f2c7d to eb43842 Compare December 11, 2024 16:17
@psrok1 psrok1 force-pushed the fix/no-eager-parents branch from eb43842 to 2d35876 Compare December 11, 2024 16:30
@psrok1 psrok1 force-pushed the fix/no-eager-parents branch from e4ccd85 to 6929065 Compare December 11, 2024 16:42
@psrok1 psrok1 marked this pull request as ready for review December 11, 2024 16:53
@psrok1 psrok1 merged commit 12d25f3 into master Dec 11, 2024
12 checks passed
@psrok1 psrok1 deleted the fix/no-eager-parents branch December 11, 2024 16:59
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.

1 participant