Skip to content

Use precalculated hasChecklists flag for checklist navigation item#9698

Draft
manuelmeister wants to merge 3 commits intoecamp:develfrom
manuelmeister:performance/prevent-checklist-request
Draft

Use precalculated hasChecklists flag for checklist navigation item#9698
manuelmeister wants to merge 3 commits intoecamp:develfrom
manuelmeister:performance/prevent-checklist-request

Conversation

@manuelmeister
Copy link
Copy Markdown
Member

With this we can save us an initial call to checklists.

@manuelmeister manuelmeister marked this pull request as draft May 6, 2026 16:02
Copy link
Copy Markdown
Member

@carlobeltrame carlobeltrame left a comment

Choose a reason for hiding this comment

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

Not only courses may use checklists, and not only checklists determine whether a camp is a course or not. Can we name this a little more neutrally, e.g. hasChecklists?

@manuelmeister manuelmeister added the deploy! Creates a feature branch deployment for this PR label May 6, 2026
@manuelmeister manuelmeister changed the title Use dynamically calculated isCourse flag for checklist navigation item Use calculated hasChecklists flag for checklist navigation item May 6, 2026
@manuelmeister manuelmeister changed the title Use calculated hasChecklists flag for checklist navigation item Use precalculated hasChecklists flag for checklist navigation item May 6, 2026
@manuelmeister manuelmeister temporarily deployed to feature-branch May 6, 2026 20:57 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Feature branch deployment ready!

Name Link
😎 Deployment https://pr9698.ecamp3.ch/
🔑 Login test@example.com / test
🕒 Last deployed at Wed May 06 2026 22:58:46 GMT+0200
🔨 Latest commit 97a3a8a658e290a06834d64c3508b4b5fe32d1bd
🔍 Latest deploy log https://github.com/ecamp/ecamp3/actions/runs/25460603984/job/74701850255
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Comment thread api/src/Entity/Camp.php
if (!$this->checklists->contains($checklist)) {
$this->checklists[] = $checklist;
$checklist->camp = $this;
$this->hasChecklists = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we also set the boolean to false when we don't have checklists?

Did you try it with a computed property instead of caching this on the camp?

#[\Override]
public function onBefore($data, Operation $operation, array $uriVariables = [], array $context = []): void {
$camp = $data->camp;
if (null === $camp || $data->isPrototype) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why don't you do that if it is a prototype?

}

$camp->hasChecklists = 1 < $this->em->getRepository(Checklist::class)->count([
'camp' => $camp,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we have an index on those 2 fields, maybe even a combined index?

('84d41dc61c69', 'Knoblauch', 4, NULL, '2023-08-08 13:33:09', '2023-08-08 13:33:09', '6e3d8bf92360', NULL, '943f3caf8ed8', '5d28f99890bc'),
('7655793a3287', 'Zucker', 800, 'g', '2023-08-08 13:33:22', '2023-08-08 13:33:22', '6e3d8bf92360', NULL, '943f3caf8ed8', '5d28f99890bc'),
('076f418a0608', 'Zauberhüte', NULL, NULL, '2024-04-01 18:08:01', '2024-04-01 18:08:01', 'f4268fba5b4b', NULL, 'c66f2f897116', '5d28f99890bc');
INSERT INTO public.material_item (id, article, quantity, unit, createtime, updatetime, materiallistid, periodid, materialnodeid, campid, done) VALUES
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems unrelated to this PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe someone forgot to actually do this as described in the Readme in dev-data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The idea of the setup is that you don't have to create a dump for each schema change. (and then have even more conflicts when we have 2 PR with schema changes)
You only have to create a new dump to either reset the data on dev, or if you want to add new data (or change existing dev data without using a migration, which is very sensible then, as you don't want to change production. But we can do data migrations only on dev too if we want to.
The rest is handled by the migrations.

For the review it is nice if you update the snapshot in a first commit, and then apply your manual changes to data.sql.
(Or generate the snapshot twice)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy! Creates a feature branch deployment for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants