From 540a682bf0e35601111aa78801984113ef799aff Mon Sep 17 00:00:00 2001 From: palash-signoz Date: Thu, 3 Mar 2022 19:10:51 +0530 Subject: [PATCH] bug: Trace search bug is resolved (#741) * bug: Trace search bug is resolved * bug: Trace search bug is resolved * chore: parseTagsToQuery is updated * chore: parseTagsToQuery is updated * chore: parseTagsToQuery is updated * chore: parseTagsToQuery is updated --- .../Trace/Search/AllTags/Tag/index.tsx | 2 +- frontend/src/container/Trace/Search/util.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx b/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx index a377de487f..f8072ab895 100644 --- a/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx +++ b/frontend/src/container/Trace/Search/AllTags/Tag/index.tsx @@ -75,7 +75,7 @@ const SingleTags = (props: AllTagsProps): JSX.Element => { value={AllMenu.find((e) => e.key === selectedOperator)?.value || ''} > {AllMenu.map((e) => ( - ))} diff --git a/frontend/src/container/Trace/Search/util.ts b/frontend/src/container/Trace/Search/util.ts index d74a133229..91e235b4a1 100644 --- a/frontend/src/container/Trace/Search/util.ts +++ b/frontend/src/container/Trace/Search/util.ts @@ -13,14 +13,14 @@ export const parseQueryToTags = (query: string): PayloadProps => { const noOfTags = query.split(' AND '); const tags: Tags = noOfTags.map((filter) => { - const isInPresent = filter.includes('IN'); - const isNotInPresent = filter.includes('NOT_IN'); + const isInPresent = filter.includes('in'); + const isNotInPresent = filter.includes('not in'); - if (!isNotInPresent || !isInPresent) { + if (!isNotInPresent && !isInPresent) { isError = true; } - const splitBy = isNotInPresent ? 'NOT_IN' : isInPresent ? 'IN' : ''; + const splitBy = isNotInPresent ? 'not in' : isInPresent ? 'in' : ''; if (splitBy.length === 0) { isError = true; @@ -40,13 +40,15 @@ export const parseQueryToTags = (query: string): PayloadProps => { const removingFirstAndLastBrackets = `${filterForTags?.slice(1, -1)}`; - const noofFilters = removingFirstAndLastBrackets.split(','); + const noofFilters = removingFirstAndLastBrackets + .split(',') + .map((e) => e.replaceAll(/"/g, '')); noofFilters.forEach((e) => { const firstChar = e.charAt(0); const lastChar = e.charAt(e.length - 1); - if (!(firstChar === '"' && lastChar === '"')) { + if (firstChar === '"' && lastChar === '"') { isError = true; } }); @@ -73,7 +75,9 @@ export const parseTagsToQuery = (tags: Tags): PayloadProps => { isError = true; } - return `${Key[0]} ${Operator} (${Values.map((e) => `"${e}"`).join(',')})`; + return `${Key[0]} ${Operator} (${Values.map((e) => { + return `"${e.replaceAll(/"/g, '')}"`; + }).join(',')})`; }) .join(' AND ');