...
 
Commits (2)
......@@ -121,10 +121,7 @@ class feeds implements Interfaces\Api
$asActivities = (bool) ($_GET['as_activities'] ?? true);
$query = null;
if (isset($_GET['query'])) {
$query = strtolower($_GET['query']);
}
$query = $_GET['query'] ?? null;
$container_guid = $_GET['container_guid'] ?? null;
$custom_type = isset($_GET['custom_type']) && $_GET['custom_type'] ? [$_GET['custom_type']] : null;
......
......@@ -34,10 +34,12 @@ class suggest implements Interfaces\Api, Interfaces\ApiIgnorePam
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 12;
$hydrate = isset($_GET['hydrate']) && $_GET['hydrate'];
$query = str_replace('#', '', $_GET['q']);
// TODO: get strict taxonomy from pages[0] when multiple suggests are implemented
try {
$entities = $search->suggest('user', $_GET['q'], $limit);
$entities = $search->suggest('user', $query, $limit);
$entities = array_values(array_filter($entities, function ($entity) {
return isset($entity['guid']);
}));
......
......@@ -91,6 +91,10 @@ class Manager
'filter_hashtags' => false,
], $opts);
if (isset($opts['query'])) {
$opts['query'] = str_replace('#', '', strtolower($opts['query']));
}
if (isset($opts['query']) && $opts['query'] && in_array($opts['type'], ['user', 'group'])) {
$result = $this->search($opts);
......
......@@ -104,6 +104,68 @@ class ManagerSpec extends ObjectBehavior
->shouldBeAResponse([$entity2, $entity1]);
}
public function it_should_get_list_by_query(
ScoredGuid $scoredGuid1,
ScoredGuid $scoredGuid2,
Entity $entity1,
Entity $entity2
)
{
$scoredGuid1->getGuid()
->shouldBeCalled()
->willReturn(5000);
$scoredGuid1->getScore()
->shouldBeCalled()
->willReturn(500);
$scoredGuid1->getOwnerGuid()
->shouldBeCalled()
->willReturn(1000);
$scoredGuid1->getTimestamp()
->shouldBeCalled()
->willReturn(2);
$entity1->get('guid')
->shouldBeCalled()
->willReturn(5000);
$scoredGuid2->getGuid()
->shouldBeCalled()
->willReturn(5001);
$scoredGuid2->getScore()
->shouldBeCalled()
->willReturn(800);
$scoredGuid2->getOwnerGuid()
->shouldBeCalled()
->willReturn(1001);
$scoredGuid2->getTimestamp()
->shouldBeCalled()
->willReturn(1);
$entity2->get('guid')
->shouldBeCalled()
->willReturn(5001);
$this->repository->getList(Argument::withEntry('query', 'activity with hashtags'))
->shouldBeCalled()
->willReturn([$scoredGuid1, $scoredGuid2]);
$this->entitiesBuilder->get(['guids' => [5000, 5001]])
->shouldBeCalled()
->willReturn([$entity1, $entity2]);
$this
->getList([
'query' => 'Activity with #hashtags',
])
->shouldBeAResponse([$entity2, $entity1]);
}
function getMatchers()
{
$matchers = [];
......