From 9ce224d4c5ba994124fec022984ec7b8bf173289 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 29 Oct 2021 21:36:57 +0200 Subject: [PATCH] fix correct number of related attributes --- src/routes/api/search.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/api/search.js b/src/routes/api/search.js index 9bdb28f3f..aaafe2787 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -247,6 +247,12 @@ function getRelatedNotes(req) { const allResults = matchingNameAndValue.concat(matchingName); + const allResultNoteIds = new Set(); + + for (const record of allResults) { + allResultNoteIds.add(record.noteId); + } + for (const record of allResults) { if (results.length >= 20) { break; @@ -260,7 +266,7 @@ function getRelatedNotes(req) { } return { - count: allResults.length, + count: allResultNoteIds.size, results }; }