Skip to content

Commit ef74410

Browse files
committed
MDEE-342: adapt feed limit reeindex to be in seconds.
1 parent 0675bde commit ef74410

4 files changed

Lines changed: 23 additions & 20 deletions

File tree

DataExporter/Model/Indexer/AllIdsResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ private function getIdsSelect(int $lastKnownId, FeedIndexMetadata $metadata, Dat
8585
)
8686
->where($whereClause, $lastKnownId);
8787

88-
if ($metadata->getFullReIndexDaysLimit() != 0) {
88+
if ($metadata->getFullReIndexSecondsLimit() != 0) {
8989
$select->where(sprintf(
90-
"s.%s >= DATE_SUB(STR_TO_DATE('%s', '%%Y-%%m-%%d %%H:%%i:%%s'), INTERVAL %d DAY)",
91-
$metadata->getSourceTableFieldOnFullReIndexDaysLimit(),
90+
"s.%s >= DATE_SUB(STR_TO_DATE('%s', '%%Y-%%m-%%d %%H:%%i:%%s'), INTERVAL %d SECOND)",
91+
$metadata->getSourceTableFieldOnFullReIndexLimit(),
9292
$dateTime->format('Y-m-d H:i:s'),
93-
$metadata->getFullReIndexDaysLimit()
93+
$metadata->getFullReIndexSecondsLimit()
9494
));
9595
}
9696

DataExporter/Model/Indexer/FeedIndexMetadata.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ class FeedIndexMetadata
6262
/**
6363
* @var int
6464
*/
65-
private $fullReindexDaysLimit;
65+
private $fullReindexSecondsLimit;
6666

6767
/**
6868
* @var string
6969
*/
70-
private $sourceTableFieldOnFullReIndexDaysLimit;
70+
private $sourceTableFieldOnFullReIndexLimit;
7171

7272
/**
7373
* @param string $feedName
@@ -79,6 +79,8 @@ class FeedIndexMetadata
7979
* @param array $feedTableMutableColumns
8080
* @param int $batchSize
8181
* @param string|null $sourceTableIdentityField
82+
* @param int $fullReIndexSecondsLimit
83+
* @param string $sourceTableFieldOnFullReIndexLimit
8284
*/
8385
public function __construct(
8486
string $feedName,
@@ -90,8 +92,8 @@ public function __construct(
9092
array $feedTableMutableColumns,
9193
int $batchSize = 100,
9294
string $sourceTableIdentityField = null,
93-
int $fullReIndexDaysLimit = 0,
94-
string $sourceTableFieldOnFullReIndexDaysLimit = 'updated_at'
95+
int $fullReIndexSecondsLimit = 0,
96+
string $sourceTableFieldOnFullReIndexLimit = 'updated_at'
9597
) {
9698
$this->feedName = $feedName;
9799
$this->sourceTableName = $sourceTableName;
@@ -102,8 +104,8 @@ public function __construct(
102104
$this->feedTableMutableColumns = $feedTableMutableColumns;
103105
$this->batchSize = $batchSize;
104106
$this->sourceTableIdentityField = $sourceTableIdentityField ?? $sourceTableField;
105-
$this->fullReindexDaysLimit = $fullReIndexDaysLimit;
106-
$this->sourceTableFieldOnFullReIndexDaysLimit = $sourceTableFieldOnFullReIndexDaysLimit;
107+
$this->fullReindexSecondsLimit = $fullReIndexSecondsLimit;
108+
$this->sourceTableFieldOnFullReIndexLimit = $sourceTableFieldOnFullReIndexLimit;
107109
}
108110

109111
/**
@@ -197,20 +199,20 @@ public function getFeedTableMutableColumns(): array
197199
}
198200

199201
/**
200-
* Determines the amount of days back when triggering a full reindex
201-
* @return int the amount in days, 0 means no limit
202+
* Determines the amount of seconds back in time when triggering a full reindex
203+
* @return int the amount in seconds, 0 means no limit
202204
*/
203-
public function getFullReIndexDaysLimit(): int
205+
public function getFullReIndexSecondsLimit(): int
204206
{
205-
return $this->fullReindexDaysLimit;
207+
return $this->fullReindexSecondsLimit;
206208
}
207209

208210
/**
209-
* Table field name to use when full reindex is limited by days back (see fullReindexDaysLimit)
211+
* Table field name to use when full reindex is limited (see fullReindexSecondsLimit)
210212
* @return string the field name
211213
*/
212-
public function getSourceTableFieldOnFullReIndexDaysLimit(): string
214+
public function getSourceTableFieldOnFullReIndexLimit(): string
213215
{
214-
return $this->sourceTableFieldOnFullReIndexDaysLimit;
216+
return $this->sourceTableFieldOnFullReIndexLimit;
215217
}
216218
}

SalesOrdersDataExporter/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ Current time will be used by default
3030
```
3131

3232
### Reindexing
33-
To export full orders data simply run reindex command:
33+
To export orders data simply run reindex command:
3434
```shell
3535
bin/magento indexer:reindex sales_order_data_exporter_v2
3636
```
37+
Note currently reindexing is limited to orders modified in the last 7 days.

SalesOrdersDataExporter/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<argument name="feedTableMutableColumns" xsi:type="array">
2020
<item name="feed_data" xsi:type="string">feed_data</item>
2121
</argument>
22-
<argument name="fullReIndexDaysLimit" xsi:type="number">7</argument>
23-
<argument name="sourceTableFieldOnFullReIndexDaysLimit" xsi:type="string">updated_at</argument>
22+
<argument name="fullReIndexSecondsLimit" xsi:type="number">604800</argument> <!-- 7 days -->
23+
<argument name="sourceTableFieldOnFullReIndexLimit" xsi:type="string">updated_at</argument>
2424
</arguments>
2525
</virtualType>
2626
<virtualType name="Magento\SalesOrdersDataExporter\Model\Indexer\OrdersFeedIndexer" type="Magento\DataExporter\Model\Indexer\FeedIndexer">

0 commit comments

Comments
 (0)