Skip to content

Commit 1076ec3

Browse files
committed
remove useless code
Signed-off-by: kkewwei <[email protected]> Signed-off-by: kewei.11 <[email protected]>
1 parent e91828a commit 1076ec3

File tree

2 files changed

+2
-53
lines changed

2 files changed

+2
-53
lines changed

src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { getIndices, responseToItemArray, dedupeMatchedItems } from './get_indices';
6+
import { getIndices, responseToItemArray } from './get_indices';
77
import { httpServiceMock } from '../../../../../../core/public/mocks';
88
import { ResolveIndexResponseItemIndexAttrs, MatchedItem } from '../types';
99
import { Observable } from 'rxjs';
@@ -160,12 +160,6 @@ describe('getIndices', () => {
160160
expect(responseToItemArray({}, getIndexTags)).toEqual([]);
161161
});
162162

163-
it('matched items are deduped', () => {
164-
const setA = [{ name: 'a' }, { name: 'b' }] as MatchedItem[];
165-
const setB = [{ name: 'b' }, { name: 'c' }] as MatchedItem[];
166-
expect(dedupeMatchedItems(setA, setB)).toHaveLength(3);
167-
});
168-
169163
describe('errors', () => {
170164
it('should handle errors gracefully', async () => {
171165
http.get.mockImplementationOnce(() => {

src/plugins/dataset_management/public/components/create_dataset_wizard/lib/get_indices.ts

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -105,32 +105,6 @@ export const getIndicesViaResolve = async ({
105105
});
106106
};
107107

108-
/**
109-
* Takes two MatchedItem[]s and returns a merged set, with the second set prrioritized over the first based on name
110-
*
111-
* @param matchedA
112-
* @param matchedB
113-
*/
114-
115-
export const dedupeMatchedItems = (matchedA: MatchedItem[], matchedB: MatchedItem[]) => {
116-
const mergedMatchedItems = matchedA.reduce((col, item) => {
117-
col[item.name] = item;
118-
return col;
119-
}, {} as Record<string, MatchedItem>);
120-
121-
matchedB.reduce((col, item) => {
122-
col[item.name] = item;
123-
return col;
124-
}, mergedMatchedItems);
125-
126-
return Object.values(mergedMatchedItems).sort((a, b) => {
127-
if (a.name > b.name) return 1;
128-
if (b.name > a.name) return -1;
129-
130-
return 0;
131-
});
132-
};
133-
134108
export async function getIndices({
135109
http,
136110
getIndexTags = () => [],
@@ -147,7 +121,6 @@ export async function getIndices({
147121
dataSourceId?: string;
148122
}): Promise<MatchedItem[]> {
149123
const pattern = rawPattern.trim();
150-
const isCCS = pattern.indexOf(':') !== -1;
151124
const requests: Array<Promise<MatchedItem[]>> = [];
152125

153126
// Searching for `*:` fails for CCS environments. The search request
@@ -184,26 +157,8 @@ export async function getIndices({
184157
});
185158
requests.push(promiseResolve);
186159

187-
if (isCCS) {
188-
// CCS supports ±1 major version. We won't be able to expect resolve endpoint to exist until v9
189-
const promiseSearch = getIndicesViaSearch({
190-
getIndexTags,
191-
pattern,
192-
searchClient,
193-
showAllIndices,
194-
dataSourceId,
195-
}).catch(() => []);
196-
requests.push(promiseSearch);
197-
}
198-
199160
const responses = await Promise.all(requests);
200-
201-
if (responses.length === 2) {
202-
const [resolveResponse, searchResponse] = responses;
203-
return dedupeMatchedItems(searchResponse, resolveResponse);
204-
} else {
205-
return responses[0];
206-
}
161+
return responses[0];
207162
}
208163

209164
export const responseToItemArray = (

0 commit comments

Comments
 (0)