Skip to content

refactor: load elements through core's shared element repository - #199

Merged
tvdeyen merged 1 commit into
mainfrom
use-shared-element-repository
Aug 20, 2026
Merged

tvdeyen merged 1 commit into
mainfrom
use-shared-element-repository

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Aug 20, 2026

Copy link
Copy Markdown
Member

What is this pull request for?

Alchemy::JsonApi::Page currently builds its element set by instantiating Alchemy::ElementsRepository.new(page_version.elements) directly. Core already exposes that same set through Alchemy::PageVersion#element_repository, so this reuses the shared seam instead of a parallel construction.

The motivation is upcoming performance work in alchemy_cms core. Core is introducing a shared element-loading path (repository memoization now, and a shared element preloader to eliminate the ingredient/tag N+1 later). By routing json_api through page_version.element_repository, this gem inherits those improvements automatically as they land in core, rather than having to mirror each change here.

The change is behaviour-preserving: element_repository still wraps the version's (eager-loaded) elements and applies the same visible filter, so serialization output and the controller's existing includes are unaffected.

Checklist

  • I have followed the Pull Request guidelines
  • I have added a detailed description into the commit message
  • Existing tests cover this change (full suite green locally: 171 examples, 0 failures)

Build the page's element set via Alchemy::PageVersion#element_repository
instead of instantiating Alchemy::ElementsRepository directly. This routes
json_api through the same element-loading seam the rest of the Alchemy
ecosystem uses, so it inherits core's behaviour automatically — the repository
memoization today, and a shared element preloader once core provides one —
rather than maintaining a parallel construction here.

The change is behaviour-preserving: element_repository still wraps the
version's (eager-loaded) elements and applies the same visible filter.
@tvdeyen
tvdeyen requested a review from a team August 20, 2026 13:08
@tvdeyen tvdeyen added the performance Performance improvement label Aug 20, 2026
@tvdeyen tvdeyen added this to the 8.4 milestone Aug 20, 2026
@tvdeyen
tvdeyen merged commit 3e90c8a into main Aug 20, 2026
16 checks passed
@tvdeyen
tvdeyen deleted the use-shared-element-repository branch August 20, 2026 13:19
@tvdeyen tvdeyen added the backport-to-8.2-stable Needs a backport to 8.2-stable label Sep 29, 2026
@tvdeyen tvdeyen removed this from the 8.4 milestone Sep 29, 2026
@alchemycms-bot

Copy link
Copy Markdown

💔 All backports failed

Status Branch Result
❌ 8.2-stable The branch "8.2-stable" does not exist

Manual backport

To create the backport manually run:

backport --pr 199

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

@alchemycms-ci-bot

Copy link
Copy Markdown
Collaborator

💚 All backports created successfully

Status Branch Result
✅ 8.2-stable

Questions ?

Please refer to the Backport tool documentation

tvdeyen added a commit that referenced this pull request Sep 29, 2026
…pository (#199) (#216)

# Backport

This will backport the following commits from `main` to `8.2-stable`:
- [refactor: load elements through core's shared element repository
(#199)](#199)

<!--- Backport version: 12.0.4 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)
@alchemycms-bot alchemycms-bot Bot mentioned this pull request Sep 29, 2026
tvdeyen added a commit that referenced this pull request Sep 29, 2026
## Release v8.2.1

<!-- Release notes generated using configuration in .github/release.yml
at 8.2-stable -->

## What's Changed
### Bug Fixes
* [8.2-stable] fix(IngredientPictureSerializer): Use picture_url (#214)
by @alchemycms-ci-bot in
#217
### Performance Improvements
* [8.2-stable] Route element visibility through ElementsRepository
(#196) by @alchemycms-ci-bot in
#215
* [8.2-stable] refactor: load elements through core's shared element
repository (#199) by @alchemycms-ci-bot in
#216

## New Contributors
* @alchemycms-ci-bot made their first contribution in
#215

**Full Changelog**:
v8.2.0...v8.2.1
---
This PR was automatically created by the prepare-release workflow.
Once merged, the gem will be automatically published to RubyGems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-8.2-stable Needs a backport to 8.2-stable performance Performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants