-
Notifications
You must be signed in to change notification settings - Fork 165
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
MAGE-1170: Handle Index options with IndexNameFetcher
#1668
base: release/3.15.0-dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like where you going with this. The IndexOptions
is a very useful abstraction.
Added some questions and comments. Please let me know what you think.
* | ||
* @return bool | ||
*/ | ||
public function isTmp(): bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should rename this to something more descriptive like:
public function isTmp(): bool; | |
public function isTemporaryIndex(): bool; |
* @return string|null | ||
*/ | ||
public function getEnforcedIndexName(): ?string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add setters as well? Or save that for v3.16?
* | ||
* @return string|null | ||
*/ | ||
public function getEnforcedIndexName(): ?string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would enforcedIndexName
be needed for anything other than legacy? If so maybe we don't need it in the interface?
return $this->hasData(IndexOptionsInterface::IS_TMP) ? | ||
(string) $this->getData(IndexOptionsInterface::IS_TMP) : | ||
false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be (bool)
?
Also since I believe DataObject
will return null
on getData()
if not defined we could probably be less verbose (null
will cast to false
).
e.g.:
return $this->hasData(IndexOptionsInterface::IS_TMP) ? | |
(string) $this->getData(IndexOptionsInterface::IS_TMP) : | |
false; | |
return (bool) $this->getData(IndexOptionsInterface::IS_TMP); |
Of course that relies on type juggling so your call here if you prefer to be explicit.
|
||
class IndexOptions extends DataObject implements IndexOptionsInterface | ||
{ | ||
public function getStoreId(): ?int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a doc block that null triggers the default store?
*/ | ||
public function copyQueryRules(string $fromIndexName, string $toIndexName, ?int $storeId = null): void | ||
public function copyQueryRules(IndexOptionsInterface $fromIndexOptions, IndexOptionsInterface $toIndexOptions): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we should call out via a doc block that copy operations cannot be performed across two different applications?
*/ | ||
public function moveIndex(string $fromIndexName, string $toIndexName, ?int $storeId = null): void | ||
public function moveIndex(IndexOptions $fromIndexOptions, IndexOptions $toIndexOptions): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for copy operations I'm thinking we should indicate that these cannot be performed across application IDs.
* @return string|null | ||
* @throws NoSuchEntityException | ||
*/ | ||
protected function getIndexName(IndexOptionsInterface $indexOptions): ?string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to relocate this getIndexName
logic into the IndexOptions
object itself?
} | ||
|
||
if (is_null($indexOptions->getIndexSuffix())) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be an exception condition?
This PR contains:
IndexOptions
model implementingIndexOptionsInterface
which would be the component of every index operation coming toAlgoliaConnector
in the futureAlgoliaHelper
class to convert all calls to the new format includingIndexOptions
modelAlgoliaConnector
class so it fetches all index names according to theInderNameFetcher
serviceAlgoliaConnector
to be able to use the IndexNameFetcher everywhere, notably in thesetLastOperationInfo
methid