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

Update of entity loading to be more efficient and avoid global addSelects #4827

Merged
merged 12 commits into from
Feb 11, 2024

Conversation

ssddanbrown
Copy link
Member

@ssddanbrown ssddanbrown commented Feb 4, 2024

  • Removes page/chpater addSelect global query, to load book slug.
  • Updates querying of all items to be limited to a few non-static classes, one per entity type.
    • This reduces the mixed-purpose of repos to focus on CRUD actions, moving out the query stuff to be usable elsewhere.
  • Makes use of our more efficient MixedEntityListLoader where appropriate.
  • Adds some database indexes where it can make a measurable performance impact.

Related to #4823

Todo

  • Migrate all book repo query usages.
  • Migrate all shelf repo query usages.
  • Migrate all chapter repo query usages.
  • Migrate all page repo query usages.
  • Migrate all page revision query usages.
  • Remove redundant Bookchild code.
  • Migrate all static book queries.
  • Migrate all static shelf queries.
  • Migrate all static chapter queries.
  • Migrate all static page queries.
  • Maybe clean up old Entities/Queries folder? Or at least do something with the old EntitiyQuery class to not be named so close to newly added classes.
  • Review existing page/chapter lists for performance and query efficiency.
  • Update API queries
  • Check API differences before/after usage, and compare with API docs, to decide on supporting old columns or indicate change for update notes.
    • Note: Changes were made to remain compatible with pre-PR state, which already aligned with docs.
    • Books
    • Shelves
    • Pages
    • Chpaters
  • Update existing page/chapter queries.
  • See if the $listAttributes is now better placed in the PageQueries class.
    • Also check how those in MixedEntityListLoader align, and share if reasonable.
  • Double check through all queries to ensure visible scope enforced where intended.

Removes page/chpater addSelect global query, to load book slug, and
instead extracts base queries to be managed in new static class, while
updating specific entitiy relation loading to use our more efficient
MixedEntityListLoader where appropriate.

Related to #4823
Also moved to a non-static approach, and added a high-level class to
allow easy access to all other entity queries, for use in mixed-entity
scenarios and easier/simpler injection.
Updated query classes to align to interface for common aligned
operations.
Extracted repeated string-identifier-based finding from page/chapter
repos to shared higher-level entity queries.
Started new class for PageRevisions too as part of these changes
Also ran auto-removal of unused imports across app folder.
- Updated name to align, and differentate from new 'XQueries' clases.
- Removed old sketchy base class with app resolving workarounds, to a
  proper injection-based approach.
- Also fixed wrong translation text used in PageQueries.
Ensures fields returned match API docs and previous versions of
BookStack where we were accidentally returning more fields than
expected.
Updates tests to cover many of these.
Also updated clockwork to ignore image requests for less noisy
debugging.
Also updated chapter page query to not be loading all page data, via new
query in PageQueries.
@ssddanbrown ssddanbrown merged commit ff8daad into development Feb 11, 2024
18 of 21 checks passed
@ssddanbrown ssddanbrown deleted the query_revamp branch February 11, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant