-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Active TM search only (dvsa/olcs-backend#154)
* feat: Filter by active TM's only * fix: Unit test * chore: PHPCS * fix: Remove common dependency * chore: Tidy up index class with abstract * fix: Missing extends
- Loading branch information
Showing
10 changed files
with
186 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/api/module/Olcs/Db/src/Service/Search/Indices/AbstractIndex.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Db\Service\Search\Indices; | ||
|
||
use InvalidArgumentException; | ||
use Olcs\Db\Service\Search\Indices\Terms\ComplexTermInterface; | ||
use Olcs\Db\Service\Search\Indices\Terms\TransportManagerLicenceStatus; | ||
|
||
abstract class AbstractIndex | ||
{ | ||
protected array $filters; | ||
|
||
/** @return ComplexTermInterface[] */ | ||
abstract public function getFilters(): array; | ||
} |
23 changes: 23 additions & 0 deletions
23
app/api/module/Olcs/Db/src/Service/Search/Indices/Person.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Db\Service\Search\Indices; | ||
|
||
use Olcs\Db\Service\Search\Indices\Terms\ComplexTermInterface; | ||
use Olcs\Db\Service\Search\Indices\Terms\TransportManagerLicenceStatus; | ||
|
||
class Person extends AbstractIndex | ||
{ | ||
/** @return ComplexTermInterface[] */ | ||
public function getFilters(): array | ||
{ | ||
if (!isset($this->filters)) { | ||
$this->filters = [ | ||
new TransportManagerLicenceStatus(), | ||
]; | ||
} | ||
|
||
return $this->filters; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/api/module/Olcs/Db/src/Service/Search/Indices/Terms/ComplexTermInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Db\Service\Search\Indices\Terms; | ||
|
||
interface ComplexTermInterface | ||
{ | ||
public function applySearch(array &$params): void; | ||
} |
38 changes: 38 additions & 0 deletions
38
app/api/module/Olcs/Db/src/Service/Search/Indices/Terms/TransportManagerLicenceStatus.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Olcs\Db\Service\Search\Indices\Terms; | ||
|
||
class TransportManagerLicenceStatus implements ComplexTermInterface | ||
{ | ||
public function applySearch(array &$params): void | ||
{ | ||
$params['must_not'][] = [ | ||
'terms' => [ | ||
'app_status_id' => [ | ||
'apsts_refused', | ||
'apsts_valid', | ||
'apsts_curtailed', | ||
'apsts_withdrawn', | ||
'apsts_cancelled', | ||
'apsts_not_submitted', | ||
], | ||
], | ||
]; | ||
$params['must_not'][] = [ | ||
'terms' => [ | ||
'lic_status' => [ | ||
'lsts_cancelled', | ||
'lsts_terminated', | ||
'lsts_withdrawn', | ||
], | ||
], | ||
]; | ||
$params['must_not'][] = [ | ||
'exists' => [ | ||
'field' => 'date_removed', | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.