core: filter out ids that have no note against them on lookup

This commit is contained in:
Abdullah Atta
2024-03-21 12:04:07 +05:00
parent 18be9fda41
commit 76e766583c

View File

@@ -78,6 +78,13 @@ export default class Lookup {
.groupBy("results.id")
.orderBy(sql`SUM(results.rank)`, "asc")
.$if(!!limit, (eb) => eb.limit(limit!))
// filter out ids that have no note against them
.where(
"results.id",
"in",
(notes || this.db.notes.all).filter.select("id")
)
.execute();
return results.map((r) => r.id);
}, notes || this.db.notes.all);