Skip to content

[Admin] Bulk errors grid #3654

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
wants to merge 1 commit into
base: 2.10.x
Choose a base branch
from
Open

Conversation

PierreGauthier
Copy link
Contributor

No description provided.

@PierreGauthier PierreGauthier force-pushed the feat-bulk-error-grid branch 5 times, most recently from d85ad2d to 26ea23d Compare July 8, 2025 09:24
@PierreGauthier PierreGauthier requested a review from rbayet July 8, 2025 09:40
Comment on lines +105 to +110
/**
* Returns the time elapsed (in seconds) since its creation after which a non-live index is to be considered ghost.
*
* @return int
*/
public function getTimeBeforeGhost(): int;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this being used anywhere...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to remove it.
I was hesitating between two solutions: injecting IndexSetting and IndexSettingHelper in \Smile\ElasticsuiteIndices\Model\IndexStatusProvider, or adding this method to IndexSetting so that only it needs to be injected in IndexStatusProvider. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so as seen together, inject indicesConfig in the helper and move the parseIndexName in the helper too as there is also a method doing preg_replace things there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this getTimeBeforeGhost in the IndexSettings model should not be needed for now.

Comment on lines +229 to +235
/**
* {@inheritDoc}
*/
public function getTimeBeforeGhost(): int
{
return $this->helper->getTimeBeforeGhost();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this being used anywhere...

Comment on lines 237 to 247
/**
* {@inheritDoc}
*/
public function parseIndexName(string $indexName): array
{
// 1. Remove prefix
$alias = $this->helper->getIndexAlias();
if (!str_starts_with($indexName, "${alias}_")) {
throw new \LogicException(sprintf('Index %s is not an elasticsuite index.', $indexName));
}
$indexName = str_replace("${alias}_", '', $indexName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about throwing an exception nor the location of the method...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum yes you're right, I'll update this to keep the original logic that return false for external index

Comment on lines 124 to 125
$indexData = $this->indexSettings->parseIndexName($indexName);
$indexDate = $indexData['suffix'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will now throw an exception everytime you have an "external" index on the cluster, won't you ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum yes you're right, I'll update this to keep the original logic that return false for external index

Comment on lines +254 to +272
preg_match_all('/{{([\w]*)}}/', $pattern, $matches);

if (!empty($matches[1])) {
$format = '';
foreach ($matches[1] as $value) {
$format .= $value;
}
$count = strlen($format);

try {
$dateString = substr(preg_replace('/[^0-9]/', '', $indexName), -$count);
$indexName = substr($indexName, 0, -strlen(preg_replace('/{{|}}/', '', $pattern)) - 1);

// Tracking indices are built monthly and does not fit with standard pattern containing datetime with hours.
$datetime = $isTrackingIndex ? false : new \Zend_Date($dateString, $format);
} catch (\Zend_Date_Exception $e) {
$datetime = false;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment the steps with that they are supposed to do so this is "debugging after a way too heavy meal" proof :)

*/
public function recordError(string $index, string $errorCode, string $reason, string $sampleIds): void
{
$data = $this->indexSettings->parseIndexName($index);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either here or in the parseIndexName method, I would put in a place a memory cache.
Since it's a big expected that on a bulk data, 99.99% of the time, the data will target the same index.
So if there is a recurring error (due, for instance, to a badly create attribute or data source), we won't spend too much time in parseIndexName which does a log of preg things...

Comment on lines +268 to +270
$datetime = $isTrackingIndex ? false : new \Zend_Date($dateString, $format);
} catch (\Zend_Date_Exception $e) {
$datetime = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can, get rid of \Zend_Date and use DateTime as we had to do on 2.11.x.
Otherwise we will have to a "fixing PR" once that branch as been merged on 2.10.x and 2.10.x on 2.11.x

'prefix' => 'magento2',
'store_code' => 'default',
'index_identifier' => 'catalog_product',
'datetime' => new \Zend_Date('20250707093823', 'YYYYMMddHHmmss'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same as before and for all the following usage)
If you can, get rid of \Zend_Date and use DateTime as we had to do on 2.11.x.
Otherwise we will have to a "fixing PR" once that branch as been merged on 2.10.x and 2.10.x on 2.11.x

@rbayet rbayet assigned PierreGauthier and unassigned rbayet Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants