-
Notifications
You must be signed in to change notification settings - Fork 70
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
Upgrade to Algolia client v2 #244
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ | |
<tag name="doctrine_mongodb.odm.event_subscriber" connection="default" /> | ||
</service> | ||
|
||
<service id="algolia_client" class="AlgoliaSearch\Client" public="false"> | ||
<argument key="$applicationID">%env(ALGOLIA_APP_ID)%</argument> | ||
<service id="algolia_client" class="Algolia\AlgoliaSearch\Client" public="false"> | ||
<factory class="Algolia\AlgoliaSearch\Client" method="create"/> | ||
<argument key="$appId ">%env(ALGOLIA_APP_ID)%</argument> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are extra spaces behind the key here. |
||
<argument key="$apiKey">%env(ALGOLIA_API_KEY)%</argument> | ||
</service> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ public function update($searchableEntities) | |
$batch = $this->doUpdate($searchableEntities); | ||
|
||
foreach ($batch as $indexName => $response) { | ||
$this->algolia->initIndex($indexName)->waitTask($response['taskID']); | ||
$this->algolia->waitTask($indexName, $response['taskID']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the rationale of not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We recently exposed waitTask in the client for 2 main reasons:
More details: algolia/algoliasearch-client-php#410 I thought it would best to avoid instanciating an index "just" for a waitTask but I didn't benchmark anything, I guess the performance gain would be negligable. It just felt easier. Note that internally,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And thanks for taking the time to review 🙏 Feedback is greatly appreciated! |
||
} | ||
|
||
return $this->formatIndexingResponse($batch); | ||
|
@@ -26,7 +26,7 @@ public function remove($searchableEntities) | |
$batch = $this->doRemove($searchableEntities); | ||
|
||
foreach ($batch as $indexName => $response) { | ||
$this->algolia->initIndex($indexName)->waitTask($response['taskID']); | ||
$this->algolia->waitTask($indexName, $response['taskID']); | ||
} | ||
|
||
return $this->formatIndexingResponse($batch); | ||
|
@@ -38,7 +38,7 @@ public function clear($indexName) | |
$batch = $this->doClear($indexName); | ||
|
||
foreach ($batch as $indexName => $response) { | ||
$this->algolia->initIndex($indexName)->waitTask($response['taskID']); | ||
$this->algolia->waitTask($indexName, $response['taskID']); | ||
} | ||
} catch (\Exception $e) { | ||
return false; | ||
|
@@ -53,7 +53,7 @@ public function delete($indexName) | |
$batch = $this->doDelete($indexName); | ||
|
||
foreach ($batch as $indexName => $response) { | ||
$this->algolia->initIndex($indexName)->waitTask($response['taskID']); | ||
$this->algolia->waitTask($indexName, $response['taskID']); | ||
} | ||
} catch (\Exception $e) { | ||
return 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.
I'm not sure what the PHP requirement of this package is (there's none in
composer.json
which is bad enough), but starting with 5.5.0 there's the::class
constant that you should use instead of magic strings. This allows IDEs to find code like this when looking for usages of a class.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 didn't specify it because I'm maintaining the same as Symfony 3.4, which requires
^5.5.9
. I will update the PR. For the client, I'm maintaing 5.3 so I sort of lost the habit of::class
^^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.
That makes sense. I would still recommend applying the PHP requirement explicitly in
composer.json
to be on the safe side to avoid relying on other libraries' constraints.