Skip to content

Commit 4bd79b9

Browse files
committed
put query negation at the end for performance
1 parent 44130c6 commit 4bd79b9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/OptimadeClient/OptimadeFilters/OptimadeRawQuery/buildQueryString.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function buildQueryString(
33
defaultNumSitesRange,
44
selectedElements,
55
numElementsRange,
6-
numSitesRange
6+
numSitesRange,
77
) {
88
const parts = [];
99

@@ -15,14 +15,15 @@ export function buildQueryString(
1515
if (state === 2) exclude.push(symbol);
1616
}
1717

18+
if (include.length) {
19+
parts.push(`elements HAS ALL ${include.map((e) => `"${e}"`).join(", ")}`);
20+
}
21+
1822
if (exclude.length) {
1923
parts.push(
20-
`NOT elements HAS ANY ${exclude.map((e) => `"${e}"`).join(", ")}`
24+
`NOT elements HAS ANY ${exclude.map((e) => `"${e}"`).join(", ")}`,
2125
);
2226
}
23-
if (include.length) {
24-
parts.push(`elements HAS ALL ${include.map((e) => `"${e}"`).join(", ")}`);
25-
}
2627

2728
// Atom count filter
2829
if (numElementsRange[0] !== defaultNumElementsRange[0]) {

0 commit comments

Comments
 (0)