Merge pull request #12603 from Budibase/optimise-get-link-documents
This commit is contained in:
commit
840847020b
|
@ -56,7 +56,7 @@ export async function getLinkDocuments(args: {
|
||||||
try {
|
try {
|
||||||
let linkRows = (await db.query(getQueryIndex(ViewName.LINK), params)).rows
|
let linkRows = (await db.query(getQueryIndex(ViewName.LINK), params)).rows
|
||||||
// filter to get unique entries
|
// filter to get unique entries
|
||||||
const foundIds: string[] = []
|
const foundIds = new Set()
|
||||||
linkRows = linkRows.filter(link => {
|
linkRows = linkRows.filter(link => {
|
||||||
// make sure anything unique is the correct key
|
// make sure anything unique is the correct key
|
||||||
if (
|
if (
|
||||||
|
@ -65,9 +65,9 @@ export async function getLinkDocuments(args: {
|
||||||
) {
|
) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const unique = foundIds.indexOf(link.id) === -1
|
const unique = !foundIds.has(link.id)
|
||||||
if (unique) {
|
if (unique) {
|
||||||
foundIds.push(link.id)
|
foundIds.add(link.id)
|
||||||
}
|
}
|
||||||
return unique
|
return unique
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue