Skip to content

Commit

Permalink
MINOR: remove chart from explore tree and ingestionPipeline from quic…
Browse files Browse the repository at this point in the history
…k filter (#17273)

* remove chart from explore tree and ingestionPipeline from quick filter

* move the const to searchClassBase

* change variable to entity type and added ingestionPipeline in tree ignore list
  • Loading branch information
Ashish8689 authored Aug 7, 2024
1 parent b6d3a2f commit c6b6c2f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useParams } from 'react-router-dom';
import { ReactComponent as IconDown } from '../../../assets/svg/ic-arrow-down.svg';
import { ReactComponent as IconRight } from '../../../assets/svg/ic-arrow-right.svg';
import { EntityFields } from '../../../enums/AdvancedSearch.enum';
import { EntityType } from '../../../enums/entity.enum';
import { ExplorePageTabs } from '../../../enums/Explore.enum';
import { SearchIndex } from '../../../enums/search.enum';
import { searchQuery } from '../../../rest/searchAPI';
Expand Down Expand Up @@ -123,7 +124,12 @@ const ExploreTree = ({ onFieldValueSelect }: ExploreTreeProps) => {
});

const aggregations = getAggregations(res.aggregations);
const buckets = aggregations[bucketToFind].buckets;
const buckets = aggregations[bucketToFind].buckets.filter(
(item) =>
!searchClassBase
.notIncludeAggregationExploreTree()
.includes(item.key as EntityType)
);
const isServiceType = bucketToFind === EntityFields.SERVICE_TYPE;
const isEntityType = bucketToFind === EntityFields.ENTITY_TYPE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { SortingField } from '../components/Explore/SortingDropDown';
import { EntityFields } from '../enums/AdvancedSearch.enum';
import { SORT_ORDER } from '../enums/common.enum';
import { EntityType } from '../enums/entity.enum';
import i18n from '../utils/i18next/LocalUtil';

export const INITIAL_SORT_FIELD = 'totalVotes';
Expand All @@ -34,6 +35,10 @@ export const SUPPORTED_EMPTY_FILTER_FIELDS = [
EntityFields.TAG,
];

export const NOT_INCLUDE_AGGREGATION_QUICK_FILTER = [
EntityType.INGESTION_PIPELINE,
];

// as it is used only in unit tests it's not needed for translation
export const tableSortingFields: SortingField[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SearchIndex } from '../enums/search.enum';
import {
getChartsOptions,
getColumnsOptions,
getOptionsFromAggregationBucket,
getSchemaFieldOptions,
getSearchDropdownLabels,
getSearchLabel,
Expand All @@ -25,6 +26,7 @@ import {
} from './AdvancedSearchUtils';
import {
highlightedItemLabel,
mockBucketOptions,
mockGetChartsOptionsData,
mockGetChartsOptionsDataWithoutDN,
mockGetChartsOptionsDataWithoutNameDN,
Expand Down Expand Up @@ -203,4 +205,14 @@ describe('AdvancedSearchUtils tests', () => {

expect(resultGetChartsOptions).toBe('chart text');
});

it('Function getOptionsFromAggregationBucket should return options which not include ingestionPipeline', () => {
const resultGetOptionsWithoutPipeline =
getOptionsFromAggregationBucket(mockBucketOptions);

expect(resultGetOptionsWithoutPipeline).toStrictEqual([
{ count: 1, key: 'pipeline', label: 'pipeline' },
{ count: 3, key: 'chart', label: 'chart' },
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import {
GLOSSARY_ASSETS_DROPDOWN_ITEMS,
LINEAGE_DROPDOWN_ITEMS,
} from '../constants/AdvancedSearch.constants';
import { NOT_INCLUDE_AGGREGATION_QUICK_FILTER } from '../constants/explore.constants';
import { AdvancedFields } from '../enums/AdvancedSearch.enum';
import { EntityType } from '../enums/entity.enum';
import { SearchIndex } from '../enums/search.enum';
import {
Bucket,
Expand Down Expand Up @@ -395,11 +397,16 @@ export const getOptionsFromAggregationBucket = (buckets: Bucket[]) => {
return [];
}

return buckets.map((option) => ({
key: option.key,
label: option.key,
count: option.doc_count ?? 0,
}));
return buckets
.filter(
(item) =>
!NOT_INCLUDE_AGGREGATION_QUICK_FILTER.includes(item.key as EntityType)
)
.map((option) => ({
key: option.key,
label: option.key,
count: option.doc_count ?? 0,
}));
};

export const getTierOptions: () => Promise<AsyncFetchListValues> = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ class SearchClassBase {
};
}
}

public notIncludeAggregationExploreTree() {
return [EntityType.CHART, EntityType.INGESTION_PIPELINE];
}
}

const searchClassBase = new SearchClassBase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* limitations under the License.
*/

import { Bucket } from 'Models';
import { SearchIndex } from '../../enums/search.enum';
import {
DatabaseServiceType,
Expand Down Expand Up @@ -414,3 +415,21 @@ export const mockGetChartsOptionsDataWithoutNameDN: SuggestOption<
],
},
};

export const mockBucketOptions: Bucket[] = [
{
key: 'pipeline',
doc_count: 1,
label: 'pipeline',
},
{
key: 'ingestionPipeline',
doc_count: 2,
label: 'ingestionPipeline',
},
{
key: 'chart',
doc_count: 3,
label: 'chart',
},
];

0 comments on commit c6b6c2f

Please sign in to comment.