1
0
Fork 0
mirror of synced 2024-10-03 02:27:06 +13:00

Optimise getLinkDocuments

This commit is contained in:
Sam Rose 2023-12-18 09:20:44 +00:00
parent 40af0ef31b
commit c5fa0806c8
No known key found for this signature in database

View file

@ -56,7 +56,7 @@ export async function getLinkDocuments(args: {
try {
let linkRows = (await db.query(getQueryIndex(ViewName.LINK), params)).rows
// filter to get unique entries
const foundIds: string[] = []
const foundIds = new Set()
linkRows = linkRows.filter(link => {
// make sure anything unique is the correct key
if (
@ -65,9 +65,9 @@ export async function getLinkDocuments(args: {
) {
return false
}
const unique = foundIds.indexOf(link.id) === -1
const unique = !foundIds.has(link.id)
if (unique) {
foundIds.push(link.id)
foundIds.add(link.id)
}
return unique
})