Skip to content

Commit

Permalink
remove duplicate relations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdroidian committed Nov 27, 2024
1 parent 66caa79 commit 0682a32
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/getDiscourseContextResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,24 @@ const getDiscourseContextResults = async ({
queries.push({
r,
complement: false,
key: `${r.id}-0`,
});
}
if (r.destination === nodeType || r.destination === "*") {
queries.push({
r,
complement: true,
key: `${r.id}-1`,
});
}
return queries;
})
// filter unique id+complement
// datalog translator combines all relations with the same id when query is built
.filter(
(query, index, allQueries) =>
allQueries.findIndex((q) => q.key === query.key) === index
)
.map(({ r, complement: isComplement }) => {
const target = isComplement ? r.source : r.destination;
const text = isComplement ? r.complement : r.label;
Expand Down
Loading

0 comments on commit 0682a32

Please sign in to comment.