-
Notifications
You must be signed in to change notification settings - Fork 6
Fix performance issue with retrieving association type codes #82
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
jakubtobiasz
wants to merge
4
commits into
CommerceWeavers:main
Choose a base branch
from
jakubtobiasz:claude/fix-issue-81-011CUNV4VpEYBHHMycNoQpbi
base: main
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5e8aee0
Fix performance issue with retrieving association type codes
claude 0b35648
Add interface for GetAssociationTypeCodeByAssociationIdQuery
claude b84f9c2
Add explicit exception handling for missing association type codes
claude 0f5cebf
Fix PHPStan type checking issue in GetAssociationTypeCodeByAssociatio…
claude 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
|
|
||
| <container | ||
| xmlns="http://symfony.com/schema/dic/services" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" | ||
| > | ||
| <services> | ||
| <service id="CommerceWeavers\SyliusAlsoBoughtPlugin\Doctrine\Query\GetAssociationTypeCodeByAssociationIdQuery"> | ||
| <argument type="service" id="sylius.manager.product_association" /> | ||
| <argument type="string">%sylius.model.product_association.class%</argument> | ||
| </service> | ||
|
|
||
| <service id="CommerceWeavers\SyliusAlsoBoughtPlugin\Doctrine\Query\GetAssociationTypeCodeByAssociationIdQueryInterface" alias="CommerceWeavers\SyliusAlsoBoughtPlugin\Doctrine\Query\GetAssociationTypeCodeByAssociationIdQuery" /> | ||
| </services> | ||
| </container> |
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
34 changes: 34 additions & 0 deletions
34
src/Doctrine/Query/GetAssociationTypeCodeByAssociationIdQuery.php
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 CommerceWeavers\SyliusAlsoBoughtPlugin\Doctrine\Query; | ||
|
|
||
| use Doctrine\ORM\EntityManagerInterface; | ||
|
|
||
| final class GetAssociationTypeCodeByAssociationIdQuery implements GetAssociationTypeCodeByAssociationIdQueryInterface | ||
| { | ||
| public function __construct( | ||
| private EntityManagerInterface $productAssociationManager, | ||
| private string $productAssociationClass, | ||
| ) { | ||
| } | ||
|
|
||
| public function get(int $associationId): ?string | ||
| { | ||
| $queryBuilder = $this->productAssociationManager->createQueryBuilder(); | ||
|
|
||
| /** @var string|null $result */ | ||
| $result = $queryBuilder | ||
| ->select('t.code') | ||
| ->from($this->productAssociationClass, 'pa') | ||
| ->join('pa.type', 't') | ||
| ->where('pa.id = :associationId') | ||
| ->setParameter('associationId', $associationId) | ||
| ->getQuery() | ||
| ->getSingleScalarResult() | ||
| ; | ||
|
|
||
| return $result; | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/Doctrine/Query/GetAssociationTypeCodeByAssociationIdQueryInterface.php
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,10 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CommerceWeavers\SyliusAlsoBoughtPlugin\Doctrine\Query; | ||
|
|
||
| interface GetAssociationTypeCodeByAssociationIdQueryInterface | ||
| { | ||
| public function get(int $associationId): ?string; | ||
| } |
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,13 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CommerceWeavers\SyliusAlsoBoughtPlugin\Exception; | ||
|
|
||
| final class ProductAssociationTypeNotFoundException extends \RuntimeException | ||
| { | ||
| public function __construct(int $associationId) | ||
| { | ||
| parent::__construct(sprintf('Product association type not found for association with id "%d".', $associationId)); | ||
| } | ||
| } |
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
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.