-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
IBX-7419: [autcomplete] Add the total number of results to the autocomplete/suggestions endpoint #38
Conversation
@@ -47,4 +56,19 @@ public function truncate(int $count): void | |||
{ | |||
$this->items = array_slice($this->items, 0, $count); | |||
} | |||
|
|||
public function increaseTotalCount(int $totalCount): void |
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.
Wouldn't increasing totalCount
when using append()
be less error prone?
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.
This method is needed because of multiple data sources. When the limit
value (for example, 5) is passed, only 5 records will be inserted using the append
method. However, it is necessary to include the total number of records that the query finds.
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.
yeah, I realised that this is probably the case later in the day, wonder how it will work with pagination tho (offset), but I guess this is not something we need (or at all if this works properly), now.
tests/lib/Serializer/Normalizer/Suggestion/SuggestionCollectionNormalizerTest.php
Outdated
Show resolved
Hide resolved
parent::__construct($items); | ||
$this->items = $items; | ||
$this->totalCount = $totalCount; |
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.
parent::__construct($items); | |
$this->items = $items; | |
$this->totalCount = $totalCount; | |
parent::__construct($items); | |
$this->items = $items; | |
$this->totalCount = $totalCount; |
|
||
public function decreaseTotalCount(int $totalCount): void | ||
{ | ||
$this->totalCount -= $totalCount; |
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.
perhaps this will not be the case but maybe something should happen when $this->totalCount
will be lower than 0
@kisztof the backend endpoint (suggestion) does not return searched contents - frontend does. |
…nNormalizerTest.php Co-authored-by: Paweł Niedzielski <pawel.niedzielski@ibexa.co>
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
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.
Regression tests passed.
This PR adds new two properties in the suggestion endpoint,
suggestionResults
andtotalCount
.http://127.0.0.1:8000/suggestion?query=ala&limit=1
The capability to adjust the totalCount via an extension point can be achieved through the use of
\Ibexa\Contracts\Search\Model\Suggestion\SuggestionCollection::increaseTotalCount
or\Ibexa\Contracts\Search\Model\Suggestion\SuggestionCollection::decreaseTotalCount
Checklist:
$ composer fix-cs
)