Skip to content

Commit

Permalink
[shopsys] product recalculation and export is now done by queue (#2917)
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin authored Dec 19, 2023
2 parents a1ed3c0 + 443e732 commit 932079f
Show file tree
Hide file tree
Showing 124 changed files with 847 additions and 3,673 deletions.
1 change: 1 addition & 0 deletions app/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DATABASE_NAME=shopsys-test

MAILER_DSN=null://null
MESSENGER_TRANSPORT_DSN=in-memory://

GOPAY_IS_PRODUCTION_MODE=false
GOPAY_EN_GOID=test-data
Expand Down
20 changes: 2 additions & 18 deletions app/config/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,9 @@ services:

# Products

Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPriceCronModule:
Shopsys\FrameworkBundle\Model\Product\Elasticsearch\ProductRecalculationCronModule:
tags:
- { name: shopsys.cron, hours: '*', minutes: '*', instanceName: products, readableName: 'Recalculate product prices' }

Shopsys\FrameworkBundle\Model\Product\ProductVisibilityImmediateCronModule:
tags:
- { name: shopsys.cron, hours: '*', minutes: '*', instanceName: products, readableName: 'Recalculate immediate product visibilities' }

Shopsys\FrameworkBundle\Model\Product\ProductVisibilityMidnightCronModule:
tags:
- { name: shopsys.cron, hours: '0', minutes: '0', instanceName: products, readableName: 'Recalculate midnight product visibilities' }

App\Model\Product\Elasticsearch\ProductExportCronModule:
tags:
- { name: shopsys.cron, hours: '0', minutes: '0', instanceName: products, readableName: "Export products to Elasticsearch" }

App\Model\Product\Elasticsearch\ProductExportChangedCronModule:
tags:
- { name: shopsys.cron, hours: '*', minutes: '*', instanceName: products, readableName: "Export changed products to Elasticsearch" }
- { name: shopsys.cron, hours: '0', minutes: '0', instanceName: products, readableName: "Dispatches all products to be recalculated and exported" }

# Akeneo import products

Expand Down
9 changes: 5 additions & 4 deletions app/config/packages/messenger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ framework:
middleware:
- 'Shopsys\FrameworkBundle\Component\Messenger\DelayedEnvelope\DelayEnvelopeMiddleware'
transports:
example_transport:
product_recalculation:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
vhost: '%env(MESSENGER_TRANSPORT_VHOST)%'
exchange:
name: example_exchange
name: product_recalculation
type: direct
queues:
example_queue: ~
product_recalculation: ~
placed_order_transport:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
Expand All @@ -30,5 +30,6 @@ framework:
multiplier: 5

routing:
Shopsys\FrameworkBundle\Component\Messenger\ExampleMessage: example_transport
Shopsys\FrameworkBundle\Model\Product\Recalculation\ProductRecalculationMessage: product_recalculation
Shopsys\FrameworkBundle\Model\Product\Recalculation\DispatchAllProductsMessage: product_recalculation
Shopsys\FrameworkBundle\Model\Order\Messenger\PlacedOrderMessage: placed_order_transport
40 changes: 0 additions & 40 deletions app/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,12 @@ services:
Shopsys\FrameworkBundle\Model\Product\ProductRepository:
alias: App\Model\Product\ProductRepository

Shopsys\FrameworkBundle\Model\Product\ProductHiddenRecalculator:
alias: App\Model\Product\ProductHiddenRecalculator

Shopsys\FrameworkBundle\Model\Product\ProductSellingDeniedRecalculator:
alias: App\Model\Product\ProductSellingDeniedRecalculator

Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityRepository:
alias: App\Model\Product\Availability\AvailabilityRepository

Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade:
alias: App\Model\Product\Availability\AvailabilityFacade

Shopsys\FrameworkBundle\Model\Product\Brand\BrandFacade:
alias: App\Model\Product\Brand\BrandFacade

Expand Down Expand Up @@ -495,21 +489,12 @@ services:
Shopsys\FrameworkBundle\Model\Product\ProductBreadcrumbGenerator:
alias: App\Model\Product\ProductBreadcrumbGenerator

Shopsys\FrameworkBundle\Model\Product\ProductVisibilityFacade:
class: App\Model\Product\ProductVisibilityFacade
tags:
# must be ran after CategoryVisibilityRepository and ProductPriceRecalculator
- { name: kernel.event_listener, event: kernel.response, method: onKernelResponse, priority: 10 }

Shopsys\FrameworkBundle\Model\Product\ProductFacade:
alias: App\Model\Product\ProductFacade

Shopsys\FrameworkBundle\Model\Product\ProductFactory:
alias: App\Model\Product\ProductFactory

Shopsys\FrameworkBundle\Model\Product\ProductVariantFacade:
alias: App\Model\Product\ProductVariantFacade

Shopsys\FrameworkBundle\Model\Product\Elasticsearch\ProductExportRepository:
alias: App\Model\Product\Elasticsearch\ProductExportRepository

Expand All @@ -525,17 +510,6 @@ services:
Shopsys\FrameworkBundle\Model\Product\Filter\ParameterFilterChoiceRepository:
alias: App\Model\Product\Filter\ParameterFilterChoiceRepository

Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterRepository:
alias: App\Model\Product\Filter\ProductFilterRepository

Shopsys\FrameworkBundle\Model\Product\ProductVisibilityRepository:
alias: App\Model\Product\ProductVisibilityRepository

Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityCalculation:
alias: App\Model\Product\Availability\ProductAvailabilityCalculation

Shopsys\FrameworkBundle\Model\Product\Availability\ProductAvailabilityRecalculator: ~

App\Model\AdvancedSearch\ProductAdvancedSearchConfig: ~

Shopsys\FrameworkBundle\Model\AdvancedSearch\ProductAdvancedSearchConfig:
Expand Down Expand Up @@ -701,9 +675,6 @@ services:

App\Model\Administrator\Mail\TwoFactorAuthenticationMail: ~

Shopsys\FrameworkBundle\Model\Product\Elasticsearch\MarkProductForExportSubscriber:
alias: App\Model\Product\Elasticsearch\MarkProductForExportSubscriber

Shopsys\FrameworkBundle\Component\Domain\DomainAwareSecurityHeadersSetter:
class: App\Component\Domain\DomainAwareSecurityHeadersSetter
tags:
Expand Down Expand Up @@ -763,10 +734,6 @@ services:
- '@snc_redis.global'
- '@snc_redis.blog_article_export_queue'

App\Component\Redis\CleanStorefrontCacheFacade:
arguments:
$storefrontGraphqlQueryClient: '@snc_redis.storefront_graphql_query'

Shopsys\FrameworkBundle\Component\Redis\RedisFacade:
alias: App\Component\Redis\RedisFacade

Expand Down Expand Up @@ -808,13 +775,6 @@ services:
App\FrontendApi\Component\ExpressionLanguage\DynamicPaginationComplexityExpressionFunction:
tags: ['overblog_graphql.expression_function']

App\Model\ImageSitemap\ImageSitemapFacade:
arguments:
- '%shopsys.sitemaps_dir%'
- '%shopsys.sitemaps_url_prefix%'

App\Model\ImageSitemap\ImageSitemapFilePrefixer: ~

App\FrontendApi\Model\Token\TokenAuthenticator: ~

Shopsys\FrontendApiBundle\Model\Token\TokenAuthenticator:
Expand Down
2 changes: 1 addition & 1 deletion app/deploy/deploy-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function merge() {
# Specify consumers configuration with the default configuration in the format:
# <consumer-name>:<transport-names-separated-by-space>:<number-of-consumers>
DEFAULT_CONSUMERS=(
"example:example_transport:1"
"product-recalculation:product_recalculation:1"
"placed_order:placed_order_transport:1"
)

Expand Down
2 changes: 1 addition & 1 deletion app/docker/php-fpm/consumer-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
TIME_LIMIT=${1:-60}

php ./bin/console messenger:consume \
example_transport \
product_recalculation \
placed_order_transport \
--time-limit=$TIME_LIMIT
4 changes: 2 additions & 2 deletions app/src/Command/CleanStorefrontQueryCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Command;

use App\Component\Redis\CleanStorefrontCacheFacade;
use Shopsys\FrameworkBundle\Component\Redis\CleanStorefrontCacheFacade;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -16,7 +16,7 @@
class CleanStorefrontQueryCacheCommand extends Command
{
/**
* @param \App\Component\Redis\CleanStorefrontCacheFacade $cleanStorefrontCacheFacade
* @param \Shopsys\FrameworkBundle\Component\Redis\CleanStorefrontCacheFacade $cleanStorefrontCacheFacade
*/
public function __construct(
private readonly CleanStorefrontCacheFacade $cleanStorefrontCacheFacade,
Expand Down
29 changes: 0 additions & 29 deletions app/src/Component/Doctrine/OrderByCollationHelper.php

This file was deleted.

1 change: 0 additions & 1 deletion app/src/Component/Doctrine/RemoveMappingsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
'outOfStockAction',
'stockQuantity',
'usingStock',
'calculatedAvailability',
],
$classMetadata,
);
Expand Down
66 changes: 0 additions & 66 deletions app/src/Component/Redis/CleanStorefrontCacheFacade.php

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/Controller/Admin/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace App\Controller\Admin;

use App\Component\Redis\CleanStorefrontCacheFacade;
use App\Model\Article\Article;
use Shopsys\FrameworkBundle\Component\ConfirmDelete\ConfirmDeleteResponseFactory;
use Shopsys\FrameworkBundle\Component\Domain\AdminDomainTabsFacade;
use Shopsys\FrameworkBundle\Component\Grid\GridFactory;
use Shopsys\FrameworkBundle\Component\Redis\CleanStorefrontCacheFacade;
use Shopsys\FrameworkBundle\Controller\Admin\ArticleController as BaseArticleController;
use Shopsys\FrameworkBundle\Model\AdminNavigation\BreadcrumbOverrider;
use Shopsys\FrameworkBundle\Model\Article\ArticleDataFactoryInterface;
Expand All @@ -35,7 +35,7 @@ class ArticleController extends BaseArticleController
* @param \Shopsys\FrameworkBundle\Component\ConfirmDelete\ConfirmDeleteResponseFactory $confirmDeleteResponseFactory
* @param \App\Model\LegalConditions\LegalConditionsFacade $legalConditionsFacade
* @param \Shopsys\FrameworkBundle\Model\Cookies\CookiesFacade $cookiesFacade
* @param \App\Component\Redis\CleanStorefrontCacheFacade $cleanStorefrontCacheFacade
* @param \Shopsys\FrameworkBundle\Component\Redis\CleanStorefrontCacheFacade $cleanStorefrontCacheFacade
*/
public function __construct(
ArticleFacade $articleFacade,
Expand Down
3 changes: 1 addition & 2 deletions app/src/Controller/Admin/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

/**
* @property \App\Component\Setting\Setting $setting
* @property \App\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @property \App\Model\Mail\MailTemplateFacade $mailTemplateFacade
* @property \App\Model\Product\Unit\UnitFacade $unitFacade
*/
Expand All @@ -37,7 +36,7 @@ class DefaultController extends BaseDefaultController
* @param \App\Model\Mail\MailTemplateFacade $mailTemplateFacade
* @param \App\Model\Product\Unit\UnitFacade $unitFacade
* @param \App\Component\Setting\Setting $setting
* @param \App\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @param \Shopsys\FrameworkBundle\Component\Cron\CronModuleFacade $cronModuleFacade
* @param \Shopsys\FrameworkBundle\Component\Grid\GridFactory $gridFactory
* @param \Shopsys\FrameworkBundle\Component\Cron\Config\CronConfig $cronConfig
Expand Down
5 changes: 2 additions & 3 deletions app/src/Controller/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* @property \App\Model\Product\ProductFacade $productFacade
* @property \App\Model\Product\ProductDataFactory $productDataFactory
* @property \App\Component\Setting\Setting $setting
* @property \App\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @property \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
* @method setSellingToUntilEndOfDay(\App\Model\Product\ProductData|null $productData)
* @method __construct(\Shopsys\FrameworkBundle\Model\Product\MassAction\ProductMassActionFacade $productMassActionFacade, \Shopsys\FrameworkBundle\Component\Grid\GridFactory $gridFactory, \App\Model\Product\ProductFacade $productFacade, \App\Model\Product\ProductDataFactory $productDataFactory, \Shopsys\FrameworkBundle\Model\AdminNavigation\BreadcrumbOverrider $breadcrumbOverrider, \Shopsys\FrameworkBundle\Model\Administrator\AdministratorGridFacade $administratorGridFacade, \Shopsys\FrameworkBundle\Model\Product\Listing\ProductListAdminFacade $productListAdminFacade, \Shopsys\FrameworkBundle\Model\AdvancedSearch\AdvancedSearchProductFacade $advancedSearchProductFacade, \App\Model\Product\ProductVariantFacade $productVariantFacade, \Shopsys\FrameworkBundle\Twig\ProductExtension $productExtension, \Shopsys\FrameworkBundle\Component\Domain\Domain $domain, \App\Model\Product\Unit\UnitFacade $unitFacade, \App\Component\Setting\Setting $setting, \App\Model\Product\Availability\AvailabilityFacade $availabilityFacade)
* @property \App\Model\Product\ProductVariantFacade $productVariantFacade
* @method __construct(\Shopsys\FrameworkBundle\Model\Product\MassAction\ProductMassActionFacade $productMassActionFacade, \Shopsys\FrameworkBundle\Component\Grid\GridFactory $gridFactory, \App\Model\Product\ProductFacade $productFacade, \App\Model\Product\ProductDataFactory $productDataFactory, \Shopsys\FrameworkBundle\Model\AdminNavigation\BreadcrumbOverrider $breadcrumbOverrider, \Shopsys\FrameworkBundle\Model\Administrator\AdministratorGridFacade $administratorGridFacade, \Shopsys\FrameworkBundle\Model\Product\Listing\ProductListAdminFacade $productListAdminFacade, \Shopsys\FrameworkBundle\Model\AdvancedSearch\AdvancedSearchProductFacade $advancedSearchProductFacade, \Shopsys\FrameworkBundle\Model\Product\ProductVariantFacade $productVariantFacade, \Shopsys\FrameworkBundle\Twig\ProductExtension $productExtension, \Shopsys\FrameworkBundle\Component\Domain\Domain $domain, \App\Model\Product\Unit\UnitFacade $unitFacade, \App\Component\Setting\Setting $setting, \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade $availabilityFacade)
* @property \Shopsys\FrameworkBundle\Model\Product\ProductVariantFacade $productVariantFacade
* @property \App\Model\Product\Unit\UnitFacade $unitFacade
*/
class ProductController extends BaseProductController
Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/Admin/RedisController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace App\Controller\Admin;

use App\Component\Redis\CleanStorefrontCacheFacade;
use Shopsys\FrameworkBundle\Component\Redis\CleanStorefrontCacheFacade;
use Shopsys\FrameworkBundle\Controller\Admin\AdminBaseController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -13,7 +13,7 @@
class RedisController extends AdminBaseController
{
/**
* @param \App\Component\Redis\CleanStorefrontCacheFacade $cleanStorefrontCacheFacade
* @param \Shopsys\FrameworkBundle\Component\Redis\CleanStorefrontCacheFacade $cleanStorefrontCacheFacade
*/
public function __construct(
private CleanStorefrontCacheFacade $cleanStorefrontCacheFacade,
Expand Down
2 changes: 1 addition & 1 deletion app/src/DataFixtures/Demo/AvailabilityDataFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AvailabilityDataFixture extends AbstractReferenceFixture
public const AVAILABILITY_PREPARING = 'availability_preparing';

/**
* @param \App\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityFacade $availabilityFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityDataFactory $availabilityDataFactory
* @param \App\Component\Setting\Setting $setting
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
Expand Down
Loading

0 comments on commit 932079f

Please sign in to comment.