Skip to content

Commit

Permalink
Merge pull request #47 from typesense/bugfix/revert-unnecessary-api-c…
Browse files Browse the repository at this point in the history
…alls

Revert Reduce unnecessary API calls
  • Loading branch information
karakhanyans committed Feb 27, 2023
2 parents bfb43f8 + 9386ea4 commit c23380e
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Engines/TypesenseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,14 @@ public function __construct(Typesense $typesense)
*/
public function update($models): void
{
$changes = $models->first()->getDirty();
$searchableArray = $models->first()->toSearchableArray();
if (!empty(array_intersect(array_keys($changes), array_keys($searchableArray)))) {
$collection = $this->typesense->getCollectionIndex($models->first());
$collection = $this->typesense->getCollectionIndex($models->first());

if ($this->usesSoftDelete($models->first()) && config('scout.soft_delete', false)) {
$models->each->pushSoftDeleteMetadata();
}

$this->typesense->importDocuments($collection, $models->map(fn($m) => $m->toSearchableArray())
->toArray());
if ($this->usesSoftDelete($models->first()) && config('scout.soft_delete', false)) {
$models->each->pushSoftDeleteMetadata();
}

$this->typesense->importDocuments($collection, $models->map(fn($m) => $m->toSearchableArray())
->toArray());
}

/**
Expand Down

0 comments on commit c23380e

Please sign in to comment.