Skip to content

Commit

Permalink
Merge pull request #38 from slub/sorting-symbols
Browse files Browse the repository at this point in the history
Sorting symbols
  • Loading branch information
dikastes authored Oct 9, 2024
2 parents bd2233b + e74fda1 commit 4374029
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 19 additions & 2 deletions Classes/Command/IndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Elastic\Elasticsearch\Client;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -787,16 +788,30 @@ protected function fetchObjects(): void

if ($name == 'published_item') {
$qb->where(
$eb->notLike('mvdb_id', $qb->createNamedParameter('AA%'))
$eb->notLike('mvdb_id', $qb->createNamedParameter('AA%')),
$eb->eq('final', 2)
);
}

$data = $qb->execute()->fetchAll();
if ($name == 'person') {
$data = Collection::wrap($data)->
map(function ($person) { return self::removeSortingSymbols($person); });
}

$this->dataObjects[$name] = $data;
}
}

protected static function removeSortingSymbols(array $person): array
{
$name = Str::of($person['name'])->
replace('˜', '')->
replace('œ', '');
$person['name'] = $name;
return $person;
}

/**
* Executes an indexing sequence
*
Expand Down Expand Up @@ -861,7 +876,9 @@ protected function index(array $config, array $bufferedObject = null): array
foreach($mmObjects as $object) {
$subKey = $object[$subKeyField];
$superKey = $object[$superKeyField];
$indexedObjects[$superKey][] = isset($subDataObjects[$subKey][0]) ? $subDataObjects[$subKey][0] : null;
if (isset($subDataObjects[$subKey][0])) {
$indexedObjects[$superKey][] = $subDataObjects[$subKey][0];
}
}
} else {
$subDataObjects = $bufferedObject ?? $this->dataObjects[$config['subObject']];
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"elasticsearch/elasticsearch": "^8",
"slub/dm-ont": "@dev",
"fluidtypo3/vhs": "^6",
"illuminate/collections": "^8"
"illuminate/collections": "^8",
"illuminate/support": "^8"
},
"config": {
"allow-plugins": {
Expand Down

0 comments on commit 4374029

Please sign in to comment.