refactor: update ExploreQuickFilters and ExploreUtils to include showDeleted and deleted parameters

This commit is contained in:
Aniket Katkar 2025-09-25 14:53:20 +05:30
parent 2b9c6afe2c
commit d2ee0aa767
3 changed files with 46 additions and 41 deletions

View File

@ -94,7 +94,8 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
key,
'',
JSON.stringify(combinedQueryFilter),
independent
independent,
showDeleted
),
key === TIER_FQN_KEY
? getTags({ parent: 'Tier', limit: 50 })
@ -159,7 +160,8 @@ const ExploreQuickFilters: FC<ExploreQuickFiltersProps> = ({
key,
value,
JSON.stringify(combinedQueryFilter),
independent
independent,
showDeleted
);
const buckets = res.data.aggregations[`sterms#${key}`].buckets;

View File

@ -168,7 +168,8 @@ export const getAggregateFieldOptions = (
field: string,
value: string,
q: string,
sourceFields?: string
sourceFields?: string,
deleted = false
) => {
const withWildCardValue = value
? `.*${escapeESReservedCharacters(value)}.*`
@ -179,6 +180,7 @@ export const getAggregateFieldOptions = (
value: withWildCardValue,
q,
sourceFields,
deleted,
};
return APIClient.get<SearchResponse<ExploreSearchIndex>>(

View File

@ -200,41 +200,6 @@ export const extractTermKeys = (objects: QueryFieldInterface[]): string[] => {
return termKeys;
};
export const getSubLevelHierarchyKey = (
isDatabaseHierarchy = false,
filterField?: ExploreQuickFilterField[],
key?: EntityFields,
value?: string
) => {
const queryFilter = {
query: { bool: {} },
};
if ((key && value) || filterField) {
(queryFilter.query.bool as EsBoolQuery).must = isUndefined(filterField)
? { term: { [key ?? '']: value } }
: getExploreQueryFilterMust(filterField);
}
const bucketMapping = isDatabaseHierarchy
? {
[EntityFields.SERVICE_TYPE]: EntityFields.SERVICE,
[EntityFields.SERVICE]: EntityFields.DATABASE_DISPLAY_NAME,
[EntityFields.DATABASE_DISPLAY_NAME]:
EntityFields.DATABASE_SCHEMA_DISPLAY_NAME,
[EntityFields.DATABASE_SCHEMA_DISPLAY_NAME]: EntityFields.ENTITY_TYPE,
}
: {
[EntityFields.SERVICE_TYPE]: EntityFields.SERVICE,
[EntityFields.SERVICE]: EntityFields.ENTITY_TYPE,
};
return {
bucket: bucketMapping[key as DatabaseFields] ?? EntityFields.SERVICE_TYPE,
queryFilter,
};
};
export const getExploreQueryFilterMust = (data: ExploreQuickFilterField[]) => {
const must = [] as Array<QueryFieldInterface>;
@ -281,6 +246,41 @@ export const getExploreQueryFilterMust = (data: ExploreQuickFilterField[]) => {
return must;
};
export const getSubLevelHierarchyKey = (
isDatabaseHierarchy = false,
filterField?: ExploreQuickFilterField[],
key?: EntityFields,
value?: string
) => {
const queryFilter = {
query: { bool: {} },
};
if ((key && value) || filterField) {
(queryFilter.query.bool as EsBoolQuery).must = isUndefined(filterField)
? { term: { [key ?? '']: value } }
: getExploreQueryFilterMust(filterField);
}
const bucketMapping = isDatabaseHierarchy
? {
[EntityFields.SERVICE_TYPE]: EntityFields.SERVICE,
[EntityFields.SERVICE]: EntityFields.DATABASE_DISPLAY_NAME,
[EntityFields.DATABASE_DISPLAY_NAME]:
EntityFields.DATABASE_SCHEMA_DISPLAY_NAME,
[EntityFields.DATABASE_SCHEMA_DISPLAY_NAME]: EntityFields.ENTITY_TYPE,
}
: {
[EntityFields.SERVICE_TYPE]: EntityFields.SERVICE,
[EntityFields.SERVICE]: EntityFields.ENTITY_TYPE,
};
return {
bucket: bucketMapping[key as DatabaseFields] ?? EntityFields.SERVICE_TYPE,
queryFilter,
};
};
export const updateTreeData = (
list: ExploreTreeNode[],
key: React.Key,
@ -360,11 +360,12 @@ export const getAggregationOptions = async (
key: string,
value: string,
filter: string,
isIndependent: boolean
isIndependent: boolean,
deleted = false
) => {
return isIndependent
? postAggregateFieldOptions(index, key, value, filter)
: getAggregateFieldOptions(index, key, value, filter);
: getAggregateFieldOptions(index, key, value, filter, undefined, deleted);
};
export const updateTreeDataWithCounts = (
@ -412,7 +413,7 @@ export const isElasticsearchError = (error: unknown): boolean => {
return false;
}
const data = axiosError.response.data as Record<string, any>;
const data = axiosError.response.data as Record<string, unknown>;
const message = data.message as string;
return (