From 09db06da3bd89de9920aaa72068438b07e9b8d22 Mon Sep 17 00:00:00 2001 From: "Praveen K.B" Date: Mon, 4 Nov 2024 12:36:00 +0530 Subject: [PATCH 1/6] Added filter_query to filtler builder --- .../Stream/components/Querier/SaveFilterModal.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/pages/Stream/components/Querier/SaveFilterModal.tsx b/src/pages/Stream/components/Querier/SaveFilterModal.tsx index 5fbce403..7e3ff286 100644 --- a/src/pages/Stream/components/Querier/SaveFilterModal.tsx +++ b/src/pages/Stream/components/Querier/SaveFilterModal.tsx @@ -22,14 +22,7 @@ interface FormObjectType extends Omit } const sanitizeFilterItem = (formObject: FormObjectType): SavedFilterType => { - const { - stream_name, - filter_name, - filter_id = '', - query, - selectedTimeRangeOption, - version = '', - } = formObject; + const { stream_name, filter_name, filter_id = '', query, selectedTimeRangeOption, version = '' } = formObject; return { filter_id, version, @@ -76,7 +69,8 @@ const SaveFilterModal = () => { filter_name: '', query: { filter_type: isSqlMode ? 'sql' : 'builder', - ...(isSqlMode ? { filter_query: custSearchQuery } : { filter_builder: appliedQuery }), + filter_query: custSearchQuery, + ...(!isSqlMode && { filter_builder: appliedQuery }), }, time_filter: { from: timeRange.startTime.toISOString(), From eab521517f95d2d5557ac1e640fb021ce8121623 Mon Sep 17 00:00:00 2001 From: "Praveen K.B" Date: Tue, 5 Nov 2024 11:36:27 +0530 Subject: [PATCH 2/6] Added filterType & parsing SQL query from URL --- src/@types/parseable/api/savedFilters.ts | 4 +-- .../components/Querier/FilterQueryBuilder.tsx | 12 ++++---- src/pages/Stream/hooks/useParamsController.ts | 22 +++++++++++--- src/pages/Stream/providers/LogsProvider.tsx | 8 ++--- src/pages/Stream/utils.ts | 29 +++++++++++++++++-- 5 files changed, 57 insertions(+), 18 deletions(-) diff --git a/src/@types/parseable/api/savedFilters.ts b/src/@types/parseable/api/savedFilters.ts index 3737b180..61996931 100644 --- a/src/@types/parseable/api/savedFilters.ts +++ b/src/@types/parseable/api/savedFilters.ts @@ -7,7 +7,7 @@ export type SavedFilterType = { filter_id: string; query: { filter_type: 'sql' | 'builder'; - filter_query?: string; + filter_query: string; filter_builder?: QueryType; }; time_filter: null | { @@ -21,7 +21,7 @@ export type CreateSavedFilterType = { filter_name: string; query: { filter_type: 'sql' | 'builder'; - filter_query?: string; + filter_query: string; filter_builder?: QueryType; }; time_filter: null | { diff --git a/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx b/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx index 69802ab0..744fb20f 100644 --- a/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx +++ b/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx @@ -116,18 +116,18 @@ const CombinatorToggle = (props: CombinatorToggleType) => { const { onCombinatorChange, isOrSelected } = props; return ( - onCombinatorChange('or')}> - OR - onCombinatorChange('and')}> AND + onCombinatorChange('or')}> + OR + ); }; diff --git a/src/pages/Stream/hooks/useParamsController.ts b/src/pages/Stream/hooks/useParamsController.ts index c64811e6..cc4b02a3 100644 --- a/src/pages/Stream/hooks/useParamsController.ts +++ b/src/pages/Stream/hooks/useParamsController.ts @@ -6,11 +6,15 @@ import { FIXED_DURATIONS } from '@/constants/timeConstants'; import dayjs from 'dayjs'; import timeRangeUtils from '@/utils/timeRangeUtils'; import moment from 'moment-timezone'; +import { filterStoreReducers, QueryType, useFilterStore } from '../providers/FilterProvider'; +import { parseSQLWithIDs } from '../utils'; + const { getRelativeStartAndEndDate, formatDateWithTimezone, getLocalTimezone } = timeRangeUtils; const { setTimeRange, onToggleView, setPerPage, setCustQuerySearchState } = logsStoreReducers; +const { applySavedFilters } = filterStoreReducers; const timeRangeFormat = 'DD-MMM-YYYY_HH-mmz'; -const keys = ['view', 'rows', 'interval', 'from', 'to', 'query']; +const keys = ['view', 'rows', 'interval', 'from', 'to', 'query', 'filterType']; const FIXED_ROWS = ['50', '100', '150', '200']; const dateToParamString = (date: Date) => { @@ -54,8 +58,9 @@ const storeToParamsObj = (opts: { page: string; rows: string; query: string; + filterType: string; }): Record => { - const { timeRange, offset, page, view, rows, query } = opts; + const { timeRange, offset, page, view, rows, query, filterType } = opts; const params: Record = { ...deriveTimeRangeParams(timeRange), view, @@ -63,6 +68,7 @@ const storeToParamsObj = (opts: { rows, page, query, + filterType, }; return _.pickBy(params, (val, key) => !_.isEmpty(val) && _.includes(keys, key)); }; @@ -84,6 +90,7 @@ const useParamsController = () => { const [viewMode] = useLogsStore((store) => store.viewMode); const [custQuerySearchState] = useLogsStore((store) => store.custQuerySearchState); const [timeRange, setLogsStore] = useLogsStore((store) => store.timeRange); + const [, setFilterStore] = useFilterStore((store) => store); const { currentOffset, currentPage, perPage } = tableOpts; @@ -97,6 +104,7 @@ const useParamsController = () => { view: viewMode, rows: `${perPage}`, query: custQuerySearchState.custSearchQuery, + filterType: custQuerySearchState.viewMode, }); const presentParams = paramsStringToParamsObj(searchParams); if (['table', 'json'].includes(presentParams.view) && presentParams.view !== storeAsParams.view) { @@ -107,7 +115,9 @@ const useParamsController = () => { } if (storeAsParams.query !== presentParams.query) { - setLogsStore((store) => setCustQuerySearchState(store, presentParams.query)); + setLogsStore((store) => setCustQuerySearchState(store, presentParams.query, presentParams.filterType)); + if (presentParams.filterType === 'filters') + setFilterStore((store) => applySavedFilters(store, parseSQLWithIDs(presentParams.query) as QueryType)); } syncTimeRangeToStore(storeAsParams, presentParams); setStoreSynced(true); @@ -122,6 +132,7 @@ const useParamsController = () => { view: viewMode, rows: `${perPage}`, query: custQuerySearchState.custSearchQuery, + filterType: custQuerySearchState.viewMode, }); const presentParams = paramsStringToParamsObj(searchParams); if (_.isEqual(storeAsParams, presentParams)) return; @@ -139,6 +150,7 @@ const useParamsController = () => { view: viewMode, rows: `${perPage}`, query: custQuerySearchState.custSearchQuery, + filterType: custQuerySearchState.viewMode, }); const presentParams = paramsStringToParamsObj(searchParams); @@ -153,7 +165,9 @@ const useParamsController = () => { } if (storeAsParams.query !== presentParams.query) { - setLogsStore((store) => setCustQuerySearchState(store, presentParams.query)); + setLogsStore((store) => setCustQuerySearchState(store, presentParams.query, presentParams.filterType)); + if (presentParams.filterType === 'filters') + setFilterStore((store) => applySavedFilters(store, parseSQLWithIDs(presentParams.query) as QueryType)); } syncTimeRangeToStore(storeAsParams, presentParams); }, [searchParams]); diff --git a/src/pages/Stream/providers/LogsProvider.tsx b/src/pages/Stream/providers/LogsProvider.tsx index b9a0ead8..684e8d42 100644 --- a/src/pages/Stream/providers/LogsProvider.tsx +++ b/src/pages/Stream/providers/LogsProvider.tsx @@ -248,7 +248,7 @@ type LogsStoreReducers = { resetQuickFilters: (store: LogsStore) => ReducerOutput; streamChangeCleanup: (store: LogsStore) => ReducerOutput; toggleQueryBuilder: (store: LogsStore, val?: boolean) => ReducerOutput; - setCustQuerySearchState: (store: LogsStore, query: string) => ReducerOutput; + setCustQuerySearchState: (store: LogsStore, query: string, viewMode: string) => ReducerOutput; resetCustQuerySearchState: (store: LogsStore) => ReducerOutput; toggleCustQuerySearchViewMode: (store: LogsStore, targetMode: 'sql' | 'filters') => ReducerOutput; toggleDeleteModal: (store: LogsStore, val?: boolean) => ReducerOutput; @@ -455,7 +455,7 @@ const toggleQueryBuilder = (store: LogsStore, val?: boolean) => { }; }; -const setCustQuerySearchState = (store: LogsStore, query: string) => { +const setCustQuerySearchState = (store: LogsStore, query: string, viewMode: string) => { const { timeRange } = store; return { custQuerySearchState: { @@ -463,8 +463,8 @@ const setCustQuerySearchState = (store: LogsStore, query: string) => { savedFilterId: null, isQuerySearchActive: true, custSearchQuery: query, - viewMode: 'sql', - activeMode: 'sql' as 'sql', + viewMode, + activeMode: viewMode === 'filters' ? ('filters' as 'filters') : ('sql' as 'sql'), }, ...getCleanStoreForRefetch(store), timeRange, diff --git a/src/pages/Stream/utils.ts b/src/pages/Stream/utils.ts index a709934d..83f8b272 100644 --- a/src/pages/Stream/utils.ts +++ b/src/pages/Stream/utils.ts @@ -1,6 +1,8 @@ import { Log } from '@/@types/parseable/api/query'; import { LogStreamSchemaData } from '@/@types/parseable/api/stream'; import { columnsToSkip } from './providers/LogsProvider'; +import { parseSQL } from 'react-querybuilder'; +import { QueryType, RuleGroupTypeOverride, RuleTypeOverride } from './providers/FilterProvider'; export const getPageSlice = (page = 1, perPage: number, data: Log[]) => { const firstPageIndex = (page - 1) * perPage; @@ -8,10 +10,33 @@ export const getPageSlice = (page = 1, perPage: number, data: Log[]) => { return data ? data.slice(firstPageIndex, lastPageIndex) : []; }; +export const parseSQLWithIDs = (sqlString: string) => { + const parsedQuery = parseSQL(sqlString) as QueryType; + + function isRuleGroup(rule: RuleTypeOverride | RuleGroupTypeOverride): rule is RuleGroupTypeOverride { + return 'combinator' in rule && 'rules' in rule; + } + + function addIds(query: QueryType | RuleGroupTypeOverride) { + if (Array.isArray(query.rules)) { + query.rules.forEach((rule) => { + rule.id = 'rule-' + Math.random(); + + if (isRuleGroup(rule)) { + addIds(rule); + } + }); + } + } + + addIds(parsedQuery); + return parsedQuery; +}; + export const makeHeadersFromSchema = (schema: LogStreamSchemaData | null): string[] => { if (schema) { - const { fields } = schema; - return fields.map((field) => field.name); + const { fields } = schema; + return fields.map((field) => field.name); } else { return []; } From 657b91d7343be68caa79ab7fc05c7b568bdcc907 Mon Sep 17 00:00:00 2001 From: "Praveen K.B" Date: Tue, 5 Nov 2024 12:46:20 +0530 Subject: [PATCH 3/6] Addressed review comments --- src/@types/parseable/api/savedFilters.ts | 2 +- src/pages/Stream/hooks/useParamsController.ts | 13 ++++++++----- src/pages/Stream/utils.ts | 8 ++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/@types/parseable/api/savedFilters.ts b/src/@types/parseable/api/savedFilters.ts index 61996931..14c42ba3 100644 --- a/src/@types/parseable/api/savedFilters.ts +++ b/src/@types/parseable/api/savedFilters.ts @@ -7,7 +7,7 @@ export type SavedFilterType = { filter_id: string; query: { filter_type: 'sql' | 'builder'; - filter_query: string; + filter_query?: string; filter_builder?: QueryType; }; time_filter: null | { diff --git a/src/pages/Stream/hooks/useParamsController.ts b/src/pages/Stream/hooks/useParamsController.ts index cc4b02a3..1ef4cad8 100644 --- a/src/pages/Stream/hooks/useParamsController.ts +++ b/src/pages/Stream/hooks/useParamsController.ts @@ -7,8 +7,7 @@ import dayjs from 'dayjs'; import timeRangeUtils from '@/utils/timeRangeUtils'; import moment from 'moment-timezone'; import { filterStoreReducers, QueryType, useFilterStore } from '../providers/FilterProvider'; -import { parseSQLWithIDs } from '../utils'; - +import { generateQueryBuilderASTFromSQL } from '../utils'; const { getRelativeStartAndEndDate, formatDateWithTimezone, getLocalTimezone } = timeRangeUtils; const { setTimeRange, onToggleView, setPerPage, setCustQuerySearchState } = logsStoreReducers; @@ -68,7 +67,7 @@ const storeToParamsObj = (opts: { rows, page, query, - filterType, + filterType: query ? filterType : '', }; return _.pickBy(params, (val, key) => !_.isEmpty(val) && _.includes(keys, key)); }; @@ -117,7 +116,9 @@ const useParamsController = () => { if (storeAsParams.query !== presentParams.query) { setLogsStore((store) => setCustQuerySearchState(store, presentParams.query, presentParams.filterType)); if (presentParams.filterType === 'filters') - setFilterStore((store) => applySavedFilters(store, parseSQLWithIDs(presentParams.query) as QueryType)); + setFilterStore((store) => + applySavedFilters(store, generateQueryBuilderASTFromSQL(presentParams.query) as QueryType), + ); } syncTimeRangeToStore(storeAsParams, presentParams); setStoreSynced(true); @@ -167,7 +168,9 @@ const useParamsController = () => { if (storeAsParams.query !== presentParams.query) { setLogsStore((store) => setCustQuerySearchState(store, presentParams.query, presentParams.filterType)); if (presentParams.filterType === 'filters') - setFilterStore((store) => applySavedFilters(store, parseSQLWithIDs(presentParams.query) as QueryType)); + setFilterStore((store) => + applySavedFilters(store, generateQueryBuilderASTFromSQL(presentParams.query) as QueryType), + ); } syncTimeRangeToStore(storeAsParams, presentParams); }, [searchParams]); diff --git a/src/pages/Stream/utils.ts b/src/pages/Stream/utils.ts index 83f8b272..8a89ab5f 100644 --- a/src/pages/Stream/utils.ts +++ b/src/pages/Stream/utils.ts @@ -10,7 +10,7 @@ export const getPageSlice = (page = 1, perPage: number, data: Log[]) => { return data ? data.slice(firstPageIndex, lastPageIndex) : []; }; -export const parseSQLWithIDs = (sqlString: string) => { +export const generateQueryBuilderASTFromSQL = (sqlString: string) => { const parsedQuery = parseSQL(sqlString) as QueryType; function isRuleGroup(rule: RuleTypeOverride | RuleGroupTypeOverride): rule is RuleGroupTypeOverride { @@ -20,7 +20,7 @@ export const parseSQLWithIDs = (sqlString: string) => { function addIds(query: QueryType | RuleGroupTypeOverride) { if (Array.isArray(query.rules)) { query.rules.forEach((rule) => { - rule.id = 'rule-' + Math.random(); + rule.id = `rule-${Math.random()}`; if (isRuleGroup(rule)) { addIds(rule); @@ -35,8 +35,8 @@ export const parseSQLWithIDs = (sqlString: string) => { export const makeHeadersFromSchema = (schema: LogStreamSchemaData | null): string[] => { if (schema) { - const { fields } = schema; - return fields.map((field) => field.name); + const { fields } = schema; + return fields.map((field) => field.name); } else { return []; } From 4bf52bef6d3332ab8b6046c5fb7accd51354fa2a Mon Sep 17 00:00:00 2001 From: "Praveen K.B" Date: Tue, 5 Nov 2024 16:47:03 +0530 Subject: [PATCH 4/6] Removed filter_builder from PUT call --- src/@types/parseable/api/savedFilters.ts | 1 - src/hooks/useSavedFilters.tsx | 5 +++- .../components/Querier/SaveFilterModal.tsx | 2 -- .../components/Querier/SavedFiltersModal.tsx | 30 ++++++++++++------- src/pages/Stream/hooks/useParamsController.ts | 4 +-- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/@types/parseable/api/savedFilters.ts b/src/@types/parseable/api/savedFilters.ts index 14c42ba3..de9a639c 100644 --- a/src/@types/parseable/api/savedFilters.ts +++ b/src/@types/parseable/api/savedFilters.ts @@ -22,7 +22,6 @@ export type CreateSavedFilterType = { query: { filter_type: 'sql' | 'builder'; filter_query: string; - filter_builder?: QueryType; }; time_filter: null | { from: string; diff --git a/src/hooks/useSavedFilters.tsx b/src/hooks/useSavedFilters.tsx index 0789ed93..e60fcbd8 100644 --- a/src/hooks/useSavedFilters.tsx +++ b/src/hooks/useSavedFilters.tsx @@ -26,7 +26,10 @@ const useSavedFiltersQuery = () => { ); const { mutate: updateSavedFilters, isLoading: isUpdating } = useMutation( - (data: { filter: SavedFilterType; onSuccess?: () => void }) => putSavedFilters(data.filter.filter_id, data.filter), + (data: { filter: SavedFilterType; onSuccess?: () => void }) => { + data.filter.query = _.omit(data.filter.query, 'filter_builder'); + return putSavedFilters(data.filter.filter_id, data.filter); + }, { onSuccess: (_data, variables) => { variables.onSuccess && variables.onSuccess(); diff --git a/src/pages/Stream/components/Querier/SaveFilterModal.tsx b/src/pages/Stream/components/Querier/SaveFilterModal.tsx index 7e3ff286..cac31a69 100644 --- a/src/pages/Stream/components/Querier/SaveFilterModal.tsx +++ b/src/pages/Stream/components/Querier/SaveFilterModal.tsx @@ -35,7 +35,6 @@ const sanitizeFilterItem = (formObject: FormObjectType): SavedFilterType => { const SaveFilterModal = () => { const [isSaveFiltersModalOpen, setFilterStore] = useFilterStore((store) => store.isSaveFiltersModalOpen); - const [appliedQuery] = useFilterStore((store) => store.appliedQuery); const [activeSavedFilters] = useAppStore((store) => store.activeSavedFilters); const [formObject, setFormObject] = useState(null); const [currentStream] = useAppStore((store) => store.currentStream); @@ -70,7 +69,6 @@ const SaveFilterModal = () => { query: { filter_type: isSqlMode ? 'sql' : 'builder', filter_query: custSearchQuery, - ...(!isSqlMode && { filter_builder: appliedQuery }), }, time_filter: { from: timeRange.startTime.toISOString(), diff --git a/src/pages/Stream/components/Querier/SavedFiltersModal.tsx b/src/pages/Stream/components/Querier/SavedFiltersModal.tsx index 6c93dd8b..c06cabb7 100644 --- a/src/pages/Stream/components/Querier/SavedFiltersModal.tsx +++ b/src/pages/Stream/components/Querier/SavedFiltersModal.tsx @@ -12,6 +12,7 @@ import classes from './styles/SavedFiltersModalStyles.module.css'; import { EmptySimple } from '@/components/Empty'; import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; import useSavedFiltersQuery from '@/hooks/useSavedFilters'; +import { generateQueryBuilderASTFromSQL } from '../../utils'; const { toggleSavedFiltersModal, resetFilters, parseQuery, applySavedFilters } = filterStoreReducers; const { applyCustomQuery, updateSavedFilterId, getCleanStoreForRefetch, setTimeRange } = logsStoreReducers; @@ -68,21 +69,30 @@ const SavedFilterItem = (props: { deleteSavedFilterMutation({ filter_id }); }, [showDeletePropmt]); + const handleTimeFilter = useCallback(() => { + if (time_filter === null || (time_filter && isStoredAndCurrentTimeRangeAreSame(time_filter.from, time_filter.to))) { + hardRefresh(); + } else { + changeTimerange(time_filter.from, time_filter.to); + } + }, [time_filter, isStoredAndCurrentTimeRangeAreSame, hardRefresh, changeTimerange]); + const onApplyFilters = useCallback(() => { - if (_.isString(query.filter_query)) { - props.onSqlSearchApply(query.filter_query, filter_id, time_filter); + if (query.filter_query) { + if (query.filter_type === 'sql') { + props.onSqlSearchApply(query.filter_query, filter_id, time_filter); + } else { + if (filter_id !== savedFilterId) { + props.onFilterBuilderQueryApply(generateQueryBuilderASTFromSQL(query.filter_query), filter_id); + } else { + handleTimeFilter(); + } + } } else if (query.filter_builder) { if (filter_id !== savedFilterId) { props.onFilterBuilderQueryApply(query.filter_builder, filter_id); } else { - if ( - time_filter === null || - (time_filter && isStoredAndCurrentTimeRangeAreSame(time_filter.from, time_filter.to)) - ) { - hardRefresh(); - } else { - changeTimerange(time_filter.from, time_filter.to); - } + handleTimeFilter(); } } }, [savedFilterId, isStoredAndCurrentTimeRangeAreSame, hardRefresh, changeTimerange]); diff --git a/src/pages/Stream/hooks/useParamsController.ts b/src/pages/Stream/hooks/useParamsController.ts index 1ef4cad8..c90d96c7 100644 --- a/src/pages/Stream/hooks/useParamsController.ts +++ b/src/pages/Stream/hooks/useParamsController.ts @@ -165,12 +165,12 @@ const useParamsController = () => { setLogsStore((store) => setPerPage(store, _.toNumber(presentParams.rows))); } - if (storeAsParams.query !== presentParams.query) { - setLogsStore((store) => setCustQuerySearchState(store, presentParams.query, presentParams.filterType)); + if (storeAsParams.query !== presentParams.query && !_.isEmpty(presentParams.query)) { if (presentParams.filterType === 'filters') setFilterStore((store) => applySavedFilters(store, generateQueryBuilderASTFromSQL(presentParams.query) as QueryType), ); + setLogsStore((store) => setCustQuerySearchState(store, presentParams.query, presentParams.filterType)); } syncTimeRangeToStore(storeAsParams, presentParams); }, [searchParams]); From 086c511aa4d8a0043c226e05884ca519c4affcca Mon Sep 17 00:00:00 2001 From: "Praveen K.B" Date: Wed, 6 Nov 2024 14:18:09 +0530 Subject: [PATCH 5/6] Addressed review comments --- src/hooks/useSavedFilters.tsx | 4 +++- .../Stream/components/Querier/FilterQueryBuilder.tsx | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/hooks/useSavedFilters.tsx b/src/hooks/useSavedFilters.tsx index e60fcbd8..a8ae5b4f 100644 --- a/src/hooks/useSavedFilters.tsx +++ b/src/hooks/useSavedFilters.tsx @@ -27,7 +27,9 @@ const useSavedFiltersQuery = () => { const { mutate: updateSavedFilters, isLoading: isUpdating } = useMutation( (data: { filter: SavedFilterType; onSuccess?: () => void }) => { - data.filter.query = _.omit(data.filter.query, 'filter_builder'); + if (_.has(data.filter.query, 'filter_builder')) { + data.filter.query = _.omit(data.filter.query, 'filter_builder'); + } return putSavedFilters(data.filter.filter_id, data.filter); }, { diff --git a/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx b/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx index 744fb20f..69802ab0 100644 --- a/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx +++ b/src/pages/Stream/components/Querier/FilterQueryBuilder.tsx @@ -116,18 +116,18 @@ const CombinatorToggle = (props: CombinatorToggleType) => { const { onCombinatorChange, isOrSelected } = props; return ( - onCombinatorChange('and')}> - AND - onCombinatorChange('or')}> OR + onCombinatorChange('and')}> + AND + ); }; From 3d1fdf62ec38a1bede9abcd0336f3027cddf3746 Mon Sep 17 00:00:00 2001 From: Praveen K B <30530587+praveen5959@users.noreply.github.com> Date: Wed, 6 Nov 2024 14:34:57 +0530 Subject: [PATCH 6/6] Added comments --- src/hooks/useSavedFilters.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hooks/useSavedFilters.tsx b/src/hooks/useSavedFilters.tsx index a8ae5b4f..45623870 100644 --- a/src/hooks/useSavedFilters.tsx +++ b/src/hooks/useSavedFilters.tsx @@ -27,6 +27,7 @@ const useSavedFiltersQuery = () => { const { mutate: updateSavedFilters, isLoading: isUpdating } = useMutation( (data: { filter: SavedFilterType; onSuccess?: () => void }) => { + // filter_builder will be deleted only for new filters. if (_.has(data.filter.query, 'filter_builder')) { data.filter.query = _.omit(data.filter.query, 'filter_builder'); }