mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
refactor(getIdsBySearch): do not search if the search content is empty
This commit is contained in:
parent
f576e45c58
commit
74ef00e9d8
1 changed files with 7 additions and 0 deletions
|
|
@ -87,6 +87,13 @@ export async function getIdsBySearch(
|
|||
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;
|
||||
if (parsedSearch) {
|
||||
query = query.where('search', '@@', sql`phraseto_tsquery(${parsedSearch})`);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue