Skip to content

Commit 3216fce

Browse files
[Uptime] Remove unused code in monitor list API (#84312)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 58d1df1 commit 3216fce

File tree

13 files changed

+54
-62
lines changed

13 files changed

+54
-62
lines changed

x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ describe('MonitorList component', () => {
125125
nextPagePagination: null,
126126
prevPagePagination: null,
127127
summaries: [testFooSummary, testBarSummary],
128-
totalSummaryCount: 2,
129128
};
130129
};
131130

@@ -164,7 +163,6 @@ describe('MonitorList component', () => {
164163
summaries: [],
165164
nextPagePagination: null,
166165
prevPagePagination: null,
167-
totalSummaryCount: 0,
168166
},
169167
loading: true,
170168
}}
@@ -236,7 +234,6 @@ describe('MonitorList component', () => {
236234
sortOrder: SortOrder.ASC,
237235
}),
238236
summaries: [testFooSummary, testBarSummary],
239-
totalSummaryCount: 2,
240237
};
241238
});
242239

@@ -265,7 +262,6 @@ describe('MonitorList component', () => {
265262
summaries: [],
266263
nextPagePagination: null,
267264
prevPagePagination: null,
268-
totalSummaryCount: 0,
269265
},
270266
loading: false,
271267
}}

x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/data.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"monitorStates": {
44
"prevPagePagination": null,
55
"nextPagePagination": null,
6-
"totalSummaryCount": 147428,
76
"summaries": [
87
{
98
"monitor_id": "andrewvc-com",

x-pack/plugins/uptime/public/lib/__mocks__/uptime_store.mock.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export const mockStore = {
7979
prevPagePagination: null,
8080
nextPagePagination: null,
8181
summaries: [],
82-
totalSummaryCount: 0,
8382
},
8483
loading: false,
8584
},

x-pack/plugins/uptime/public/state/reducers/monitor_list.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const initialState: MonitorList = {
2020
nextPagePagination: null,
2121
prevPagePagination: null,
2222
summaries: [],
23-
totalSummaryCount: 0,
2423
},
2524
loading: false,
2625
};

x-pack/plugins/uptime/public/state/selectors/__tests__/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ describe('state selectors', () => {
7878
prevPagePagination: null,
7979
nextPagePagination: null,
8080
summaries: [],
81-
totalSummaryCount: 0,
8281
},
8382
loading: false,
8483
},

x-pack/plugins/uptime/server/lib/requests/get_snapshot_counts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { UMElasticsearchQueryFn } from '../adapters';
88
import { CONTEXT_DEFAULTS } from '../../../common/constants';
99
import { Snapshot } from '../../../common/runtime_types';
1010
import { QueryContext } from './search';
11+
import { ESFilter } from '../../../../../typings/elasticsearch';
1112

1213
export interface GetSnapshotCountParams {
1314
dateRangeStart: string;
@@ -42,15 +43,15 @@ const statusCount = async (context: QueryContext): Promise<Snapshot> => {
4243
});
4344

4445
return (
45-
res.aggregations?.counts?.value ?? {
46+
(res.aggregations?.counts?.value as Snapshot) ?? {
4647
total: 0,
4748
up: 0,
4849
down: 0,
4950
}
5051
);
5152
};
5253

53-
const statusCountBody = (filters: any): any => {
54+
const statusCountBody = (filters: ESFilter[]) => {
5455
return {
5556
size: 0,
5657
query: {

x-pack/plugins/uptime/server/lib/requests/search/__tests__/query_context.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { QueryContext } from '../query_context';
88
import { CursorPagination } from '../types';
99
import { CursorDirection, SortOrder } from '../../../../../common/runtime_types';
10+
import { getUptimeESMockClient } from '../../__tests__/helper';
1011

1112
describe(QueryContext, () => {
1213
// 10 minute range
@@ -19,7 +20,17 @@ describe(QueryContext, () => {
1920
};
2021

2122
let qc: QueryContext;
22-
beforeEach(() => (qc = new QueryContext({}, rangeStart, rangeEnd, pagination, null, 10)));
23+
beforeEach(
24+
() =>
25+
(qc = new QueryContext(
26+
getUptimeESMockClient().uptimeEsClient,
27+
rangeStart,
28+
rangeEnd,
29+
pagination,
30+
null,
31+
10
32+
))
33+
);
2334

2435
describe('dateRangeFilter()', () => {
2536
const expectedRange = {

x-pack/plugins/uptime/server/lib/requests/search/__tests__/test_helpers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { CursorPagination } from '../types';
88
import { CursorDirection, SortOrder } from '../../../../../common/runtime_types';
99
import { QueryContext } from '../query_context';
10+
import { getUptimeESMockClient } from '../../__tests__/helper';
1011

1112
export const nextPagination = (key: any): CursorPagination => {
1213
return {
@@ -16,5 +17,13 @@ export const nextPagination = (key: any): CursorPagination => {
1617
};
1718
};
1819
export const simpleQueryContext = (): QueryContext => {
19-
return new QueryContext(undefined, '', '', nextPagination('something'), undefined, 0, '');
20+
return new QueryContext(
21+
getUptimeESMockClient().uptimeEsClient,
22+
'',
23+
'',
24+
nextPagination('something'),
25+
undefined,
26+
0,
27+
''
28+
);
2029
};

x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import { set } from '@elastic/safer-lodash-set';
8-
import { get } from 'lodash';
98
import { QueryContext } from './query_context';
109

1110
/**
@@ -21,9 +20,10 @@ export const findPotentialMatches = async (
2120
) => {
2221
const { body: queryResult } = await query(queryContext, searchAfter, size);
2322
const monitorIds: string[] = [];
24-
get<any>(queryResult, 'aggregations.monitors.buckets', []).forEach((b: any) => {
23+
24+
(queryResult.aggregations?.monitors.buckets ?? []).forEach((b) => {
2525
const monitorId = b.key.monitor_id;
26-
monitorIds.push(monitorId);
26+
monitorIds.push(monitorId as string);
2727
});
2828

2929
return {
@@ -53,11 +53,6 @@ const queryBody = async (queryContext: QueryContext, searchAfter: any, size: num
5353
size: 0,
5454
query: { bool: { filter: filters } },
5555
aggs: {
56-
has_timespan: {
57-
filter: {
58-
exists: { field: 'monitor.timespan' },
59-
},
60-
},
6156
monitors: {
6257
composite: {
6358
size,

0 commit comments

Comments
 (0)