Skip to content

Commit

Permalink
pkp#8710 Added optional maxSearchKeywords parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Aug 25, 2023
1 parent 33d7922 commit f477ec8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions classes/submission/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ abstract class Collector implements CollectorInterface
public string $orderBy = self::ORDERBY_DATE_SUBMITTED;
public string $orderDirection = 'DESC';
public ?string $searchPhrase = null;
public ?int $maxSearchKeywords = null;
public ?array $statuses = null;
public ?array $stageIds = null;
public ?array $doiStatuses = null;
Expand Down Expand Up @@ -207,9 +208,10 @@ public function assignedTo($assignedTo): AppCollector
/**
* Limit results to submissions matching this search query
*/
public function searchPhrase(?string $phrase): AppCollector
public function searchPhrase(?string $phrase, ?int $maxSearchKeywords = null): AppCollector
{
$this->searchPhrase = $phrase;
$this->maxSearchKeywords = $maxSearchKeywords;
return $this;
}

Expand Down Expand Up @@ -293,7 +295,9 @@ public function getQueryBuilder(): Builder
}

// Prepare keywords (allows short and numeric words)
$keywords = collect(Application::getSubmissionSearchIndex()->filterKeywords($this->searchPhrase, false, true, true))->unique();
$keywords = collect(Application::getSubmissionSearchIndex()->filterKeywords($this->searchPhrase, false, true, true))
->unique()
->take($this->maxSearchKeywords ?? PHP_INT_MAX);

// Setup the order by
switch ($this->orderBy) {
Expand Down

0 comments on commit f477ec8

Please sign in to comment.