-
Notifications
You must be signed in to change notification settings - Fork 67
Use precalculated hasChecklists flag for checklist navigation item #9698
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
Open
manuelmeister
wants to merge
8
commits into
ecamp:devel
Choose a base branch
from
manuelmeister:performance/prevent-checklist-request
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
46f5680
Use dynamically calculated isCourse flag for checklist navigation item
manuelmeister b593324
Reload camp after creation of checklist
manuelmeister 97a3a8a
Compute hasChecklists on creation and removal of checklists
manuelmeister 3e7f866
Simplify checklist flag processor logic
manuelmeister 668dfe2
Keep camp checklist flag in sync on entity
manuelmeister 139be18
Merge branch 'devel' into performance/prevent-checklist-request
manuelmeister d3fd49a
Merge remote-tracking branch 'refs/remotes/upstream/devel' into perfo…
manuelmeister 5bf9226
Replace hasChecklists with computed query
manuelmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace DataMigrations; | ||
|
|
||
| use Doctrine\DBAL\Schema\Schema; | ||
| use Doctrine\Migrations\AbstractMigration; | ||
|
|
||
| require_once __DIR__.'/helpers.php'; | ||
|
|
||
| final class Version202605062223 extends AbstractMigration { | ||
| #[\Override] | ||
| public function getDescription(): string { | ||
| return 'Add hasChecklist flag'; | ||
| } | ||
|
|
||
| public function up(Schema $schema): void { | ||
| // START PHP CODE | ||
| $this->addSql(createTruncateDatabaseCommand()); | ||
|
|
||
| $statements = getStatementsForMigrationFile(); | ||
| foreach ($statements as $statement) { | ||
| if (trim($statement)) { | ||
| $this->addSql($statement); | ||
| } | ||
| } | ||
| // END PHP CODE | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function down(Schema $schema): void {} | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace DoctrineMigrations; | ||
|
|
||
| use Doctrine\DBAL\Schema\Schema; | ||
| use Doctrine\Migrations\AbstractMigration; | ||
|
|
||
| final class Version20260506181000 extends AbstractMigration { | ||
| #[\Override] | ||
| public function getDescription(): string { | ||
| return 'Add persisted hasChecklists flag on camps'; | ||
| } | ||
|
|
||
| public function up(Schema $schema): void { | ||
| $this->addSql('ALTER TABLE camp ADD hasChecklists BOOLEAN DEFAULT false NOT NULL'); | ||
| $this->addSql(<<<'SQL' | ||
| UPDATE camp | ||
| SET hasChecklists = true | ||
| WHERE EXISTS ( | ||
| SELECT 1 | ||
| FROM checklist | ||
| WHERE checklist.campId = camp.id | ||
| AND checklist.isPrototype = false | ||
| ) | ||
| SQL); | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function down(Schema $schema): void { | ||
| $this->addSql('ALTER TABLE camp DROP hasChecklists'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| namespace App\State; | ||
|
|
||
| use ApiPlatform\Metadata\Operation; | ||
| use ApiPlatform\State\ProcessorInterface; | ||
| use App\Entity\Checklist; | ||
| use App\State\Util\AbstractRemoveProcessor; | ||
| use Doctrine\ORM\EntityManagerInterface; | ||
|
|
||
| /** | ||
| * @template-extends AbstractRemoveProcessor<Checklist> | ||
| */ | ||
| class ChecklistRemoveProcessor extends AbstractRemoveProcessor { | ||
| public function __construct( | ||
| ProcessorInterface $decorated, | ||
| private readonly EntityManagerInterface $em | ||
| ) { | ||
| parent::__construct($decorated); | ||
| } | ||
|
|
||
| /** | ||
| * @param Checklist $data | ||
| */ | ||
| #[\Override] | ||
| public function onBefore($data, Operation $operation, array $uriVariables = [], array $context = []): void { | ||
| $camp = $data->camp; | ||
| if (null === $camp || $data->isPrototype) { | ||
|
manuelmeister marked this conversation as resolved.
Outdated
|
||
| return; | ||
| } | ||
|
|
||
| $camp->hasChecklists = 1 < $this->em->getRepository(Checklist::class)->count([ | ||
| 'camp' => $camp, | ||
|
manuelmeister marked this conversation as resolved.
Outdated
|
||
| 'isPrototype' => false, | ||
| ]); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.