mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Merge branch 'fix-do-not-search-when-empty-content' into 'main'
refactor(getIdsBySearch): do not search if the search content is empty See merge request soapbox-pub/ditto!599
This commit is contained in:
commit
d0f53f5601
1 changed files with 7 additions and 0 deletions
|
|
@ -87,6 +87,13 @@ export async function getIdsBySearch(
|
||||||
query = query.where('pubkey', 'in', pubkeys);
|
query = query.where('pubkey', 'in', pubkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there is not a specific content to search, return the query already
|
||||||
|
// This is useful if the person only makes a query search such as `domain:patrickdosreis.com`
|
||||||
|
if (!parsedSearch.length) {
|
||||||
|
const ids = new Set((await query.execute()).map(({ id }) => id));
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
let fallbackQuery = query;
|
let fallbackQuery = query;
|
||||||
if (parsedSearch) {
|
if (parsedSearch) {
|
||||||
query = query.where('search', '@@', sql`phraseto_tsquery(${parsedSearch})`);
|
query = query.where('search', '@@', sql`phraseto_tsquery(${parsedSearch})`);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue