forked from mirror/pixelfed
Update SearchApiV2Service, improve query performance
This commit is contained in:
parent
e0c3dae324
commit
4d1f281144
1 changed files with 2 additions and 2 deletions
|
@ -87,7 +87,7 @@ class SearchApiV2Service
|
||||||
$limit = $this->query->input('limit') ?? 20;
|
$limit = $this->query->input('limit') ?? 20;
|
||||||
$offset = $this->query->input('offset') ?? 0;
|
$offset = $this->query->input('offset') ?? 0;
|
||||||
$rawQuery = $initalQuery ? $initalQuery : $this->query->input('q');
|
$rawQuery = $initalQuery ? $initalQuery : $this->query->input('q');
|
||||||
$query = '%' . $rawQuery . '%';
|
$query = $rawQuery . '%';
|
||||||
if(Str::substrCount($rawQuery, '@') >= 1 && Str::contains($rawQuery, config('pixelfed.domain.app'))) {
|
if(Str::substrCount($rawQuery, '@') >= 1 && Str::contains($rawQuery, config('pixelfed.domain.app'))) {
|
||||||
$deliminatorCount = Str::substrCount($rawQuery, '@');
|
$deliminatorCount = Str::substrCount($rawQuery, '@');
|
||||||
$query = explode('@', $rawQuery)[$deliminatorCount == 1 ? 0 : 1];
|
$query = explode('@', $rawQuery)[$deliminatorCount == 1 ? 0 : 1];
|
||||||
|
@ -123,7 +123,7 @@ class SearchApiV2Service
|
||||||
$mastodonMode = self::$mastodonMode;
|
$mastodonMode = self::$mastodonMode;
|
||||||
$limit = $this->query->input('limit') ?? 20;
|
$limit = $this->query->input('limit') ?? 20;
|
||||||
$offset = $this->query->input('offset') ?? 0;
|
$offset = $this->query->input('offset') ?? 0;
|
||||||
$query = '%' . $this->query->input('q') . '%';
|
$query = $this->query->input('q') . '%';
|
||||||
return Hashtag::where('can_search', true)
|
return Hashtag::where('can_search', true)
|
||||||
->where('name', 'like', $query)
|
->where('name', 'like', $query)
|
||||||
->offset($offset)
|
->offset($offset)
|
||||||
|
|
Loading…
Reference in a new issue