returns limited results

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
feature/noid/sql-rewrite-0929
Maxence Lange 2019-08-01 12:04:38 -01:00
rodzic e08c50ff9a
commit 8b7ecde8ef
5 zmienionych plików z 19 dodań i 9 usunięć

Wyświetl plik

@ -810,7 +810,7 @@ class LocalController extends Controller {
}
try {
$tags = $this->hashtagService->searchHashtags($search);
$tags = $this->hashtagService->searchHashtags($search, false);
return $this->success(['tags' => $tags, 'exact' => $match]);
} catch (Exception $e) {

Wyświetl plik

@ -37,7 +37,6 @@ use Doctrine\DBAL\Query\QueryBuilder;
use Exception;
use OC\DB\SchemaWrapper;
use OCA\Social\AP;
use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\Actor\Person;
@ -307,10 +306,13 @@ class CoreRequestBuilder {
*
* @param IQueryBuilder $qb
* @param string $hashtag
* @param bool $all
*/
protected function searchInHashtag(IQueryBuilder &$qb, string $hashtag) {
protected function searchInHashtag(IQueryBuilder &$qb, string $hashtag, bool $all = false) {
$dbConn = $this->dbConnection;
$this->searchInDBField($qb, 'hashtag', '%' . $dbConn->escapeLikeParameter($hashtag) . '%');
$this->searchInDBField(
$qb, 'hashtag', (($all) ? '%' : '') . $dbConn->escapeLikeParameter($hashtag) . '%'
);
}

Wyświetl plik

@ -118,12 +118,13 @@ class HashtagsRequest extends HashtagsRequestBuilder {
/**
* @param string $hashtag
* @param bool $all
*
* @return array
*/
public function searchHashtags(string $hashtag): array {
public function searchHashtags(string $hashtag, bool $all): array {
$qb = $this->getHashtagsSelectSql();
$this->searchInHashtag($qb, $hashtag);
$this->searchInHashtag($qb, $hashtag, $all);
$this->limitResults($qb, 25);
$hashtags = [];

Wyświetl plik

@ -36,6 +36,8 @@ use OCA\Social\Db\HashtagsRequest;
use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\HashtagDoesNotExistException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Model\ActivityPub\Object\Note;
use OCA\Social\Model\ActivityPub\Stream;
@ -100,6 +102,8 @@ class HashtagService {
/**
* @return int
* @throws DateTimeException
* @throws ItemUnknownException
* @throws SocialAppConfigException
*/
public function manageHashtags(): int {
$current = $this->hashtagsRequest->getAll();
@ -146,11 +150,12 @@ class HashtagService {
/**
* @param string $hashtag
* @param bool $all
*
* @return array
*/
public function searchHashtags(string $hashtag): array {
return $this->hashtagsRequest->searchHashtags($hashtag);
public function searchHashtags(string $hashtag, bool $all = false): array {
return $this->hashtagsRequest->searchHashtags($hashtag, $all);
}
@ -159,6 +164,8 @@ class HashtagService {
*
* @return Stream[]
* @throws DateTimeException
* @throws ItemUnknownException
* @throws SocialAppConfigException
*/
private function getTrendSince(int $timestamp): array {
$result = [];

Wyświetl plik

@ -139,7 +139,7 @@ class SearchService {
}
try {
$hashtags = $this->hashtagService->searchHashtags($search);
$hashtags = $this->hashtagService->searchHashtags($search, true);
$result['result'] = $hashtags;
} catch (Exception $e) {
}