Skip to content

Commit

Permalink
refactor: synchronization service and connected services
Browse files Browse the repository at this point in the history
  • Loading branch information
fox-john committed Jul 26, 2024
1 parent 0843e8e commit 0f258bb
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 116 deletions.
9 changes: 9 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class Config
const COLLECTION_WISHLISTS = 'wishlists';
const COLLECTION_WISHLIST_PRODUCTS = 'wishlist_products';

const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s';

const RANDOM_SYNC_CHECK_MAX = 20;
const INCREMENTAL_SYNC_MAX_ITEMS_PER_SHOP_CONTENT = 100000;

const INCREMENTAL_TYPE_ADD = 'incremental_type_add';
const INCREMENTAL_TYPE_UPDATE = 'incremental_type_update';
const INCREMENTAL_TYPE_DELETE = 'incremental_type_delete';

/**
* @param mixed $message
*
Expand Down
4 changes: 1 addition & 3 deletions src/Controller/AbstractApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use PrestaShop\Module\PsEventbus\Service\PsAccountsAdapterService;
use PrestaShop\Module\PsEventbus\Service\SynchronizationService;

const MYSQL_DATE_FORMAT = 'Y-m-d H:i:s';

abstract class AbstractApiController extends \ModuleFrontController
{
/**
Expand Down Expand Up @@ -187,7 +185,7 @@ protected function handleDataSync(PaginatedApiDataProviderInterface $dataProvide
$configurationRepository = $this->module->getService(\PrestaShop\Module\PsEventbus\Repository\ConfigurationRepository::class);
$timezone = (string) $configurationRepository->get('PS_TIMEZONE');

$dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(MYSQL_DATE_FORMAT);
$dateNow = (new \DateTime('now', new \DateTimeZone($timezone)))->format(Config::MYSQL_DATE_FORMAT);
$offset = 0;
$incrementalSync = false;
$response = [];
Expand Down
10 changes: 10 additions & 0 deletions src/Interfaces/ShopContentServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace PrestaShop\Module\PsEventbus\Interfaces;

interface ShopContentServiceInterface
{
public function getContentsForFull($offset, $limit, $langIso = null, $debug = false);
public function getContentsForIncremental($limit, $contentIds, $langIso = null, $debug = false);
public function countFullSyncContentLeft($offset, $langIso = null);
}
Loading

0 comments on commit 0f258bb

Please sign in to comment.