Skip to content

Commit 7f336b4

Browse files
[Uptime] Remove redundant adapter function (#56980)
* Remove get_doc_count function in favor of index status function. * Rename adapter function. * Remove obsolete import. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent f890776 commit 7f336b4

File tree

11 files changed

+12
-105
lines changed

11 files changed

+12
-105
lines changed

x-pack/legacy/plugins/uptime/common/graphql/introspection.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@
7272
"isDeprecated": false,
7373
"deprecationReason": null
7474
},
75-
{
76-
"name": "getDocCount",
77-
"description": "Gets the number of documents in the target index",
78-
"args": [],
79-
"type": {
80-
"kind": "NON_NULL",
81-
"name": null,
82-
"ofType": { "kind": "OBJECT", "name": "DocCount", "ofType": null }
83-
},
84-
"isDeprecated": false,
85-
"deprecationReason": null
86-
},
8775
{
8876
"name": "getMonitors",
8977
"description": "",

x-pack/legacy/plugins/uptime/common/graphql/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export type UnsignedInteger = any;
1717
export interface Query {
1818
/** Get a list of all recorded pings for all monitors */
1919
allPings: PingResults;
20-
/** Gets the number of documents in the target index */
21-
getDocCount: DocCount;
2220

2321
getMonitors?: LatestMonitorsResult | null;
2422

x-pack/legacy/plugins/uptime/server/graphql/monitor_states/resolvers.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = (
4747
? JSON.parse(decodeURIComponent(pagination))
4848
: CONTEXT_DEFAULTS.CURSOR_PAGINATION;
4949
const [
50-
totalSummaryCount,
50+
indexStatus,
5151
{ summaries, nextPagePagination, prevPagePagination },
5252
] = await Promise.all([
53-
libs.requests.getDocCount({ callES: APICaller }),
53+
libs.requests.getIndexStatus({ callES: APICaller }),
5454
libs.requests.getMonitorStates({
5555
callES: APICaller,
5656
dateRangeStart,
@@ -63,6 +63,9 @@ export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = (
6363
statusFilter: statusFilter || undefined,
6464
}),
6565
]);
66+
67+
const totalSummaryCount = indexStatus?.docCount ?? { count: undefined };
68+
6669
return {
6770
summaries,
6871
nextPagePagination,
@@ -71,7 +74,7 @@ export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = (
7174
};
7275
},
7376
async getStatesIndexStatus(_resolver, {}, { APICaller }): Promise<StatesIndexStatus> {
74-
return await libs.requests.getStatesIndexStatus({ callES: APICaller });
77+
return await libs.requests.getIndexStatus({ callES: APICaller });
7578
},
7679
},
7780
};

x-pack/legacy/plugins/uptime/server/graphql/pings/resolvers.ts

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

77
import { UMResolver } from '../../../common/graphql/resolver_types';
8-
import { AllPingsQueryArgs, DocCount, PingResults } from '../../../common/graphql/types';
8+
import { AllPingsQueryArgs, PingResults } from '../../../common/graphql/types';
99
import { UMServerLibs } from '../../lib/lib';
1010
import { UMContext } from '../types';
1111
import { CreateUMGraphQLResolvers } from '../types';
@@ -17,19 +17,15 @@ export type UMAllPingsResolver = UMResolver<
1717
UMContext
1818
>;
1919

20-
export type UMGetDocCountResolver = UMResolver<DocCount | Promise<DocCount>, any, never, UMContext>;
21-
2220
export interface UMPingResolver {
2321
allPings: () => PingResults;
24-
getDocCount: () => number;
2522
}
2623

2724
export const createPingsResolvers: CreateUMGraphQLResolvers = (
2825
libs: UMServerLibs
2926
): {
3027
Query: {
3128
allPings: UMAllPingsResolver;
32-
getDocCount: UMGetDocCountResolver;
3329
};
3430
} => ({
3531
Query: {
@@ -49,8 +45,5 @@ export const createPingsResolvers: CreateUMGraphQLResolvers = (
4945
location,
5046
});
5147
},
52-
async getDocCount(_resolver, _args, { APICaller }): Promise<DocCount> {
53-
return libs.requests.getDocCount({ callES: APICaller });
54-
},
5548
},
5649
});

x-pack/legacy/plugins/uptime/server/graphql/pings/schema.gql.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ export const pingsSchema = gql`
3838
"Optional: agent location to filter by."
3939
location: String
4040
): PingResults!
41-
42-
"Gets the number of documents in the target index"
43-
getDocCount: DocCount!
4441
}
4542
4643
type ContainerImage {

x-pack/legacy/plugins/uptime/server/lib/requests/__tests__/get_doc_count.test.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

x-pack/legacy/plugins/uptime/server/lib/requests/get_doc_count.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

x-pack/legacy/plugins/uptime/server/lib/requests/get_states_index_status.ts renamed to x-pack/legacy/plugins/uptime/server/lib/requests/get_index_status.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import { UMElasticsearchQueryFn } from '../adapters';
88
import { StatesIndexStatus } from '../../../common/graphql/types';
99
import { INDEX_NAMES } from '../../../common/constants';
1010

11-
export const getStatesIndexStatus: UMElasticsearchQueryFn<{}, StatesIndexStatus> = async ({
12-
callES,
13-
}) => {
11+
export const getIndexStatus: UMElasticsearchQueryFn<{}, StatesIndexStatus> = async ({ callES }) => {
1412
const {
1513
_shards: { total },
1614
count,

x-pack/legacy/plugins/uptime/server/lib/requests/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
export { getDocCount } from './get_doc_count';
87
export { getFilterBar, GetFilterBarParams } from './get_filter_bar';
98
export { getUptimeIndexPattern as getIndexPattern } from './get_index_pattern';
109
export { getLatestMonitor, GetLatestMonitorParams } from './get_latest_monitor';
@@ -17,4 +16,4 @@ export { getPings, GetPingsParams } from './get_pings';
1716
export { getPingHistogram, GetPingHistogramParams } from './get_ping_histogram';
1817
export { UptimeRequests } from './uptime_requests';
1918
export { getSnapshotCount, GetSnapshotCountParams } from './get_snapshot_counts';
20-
export { getStatesIndexStatus } from './get_states_index_status';
19+
export { getIndexStatus } from './get_index_status';

x-pack/legacy/plugins/uptime/server/lib/requests/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { DocCount, Ping, PingResults } from '../../../common/graphql/types';
7+
import { Ping, PingResults } from '../../../common/graphql/types';
88
import { UMElasticsearchQueryFn } from '../adapters';
99
import { GetPingHistogramParams, HistogramResult } from '../../../common/types';
1010

@@ -54,11 +54,6 @@ export interface UMPingsAdapter {
5454
getLatestMonitorStatus: UMElasticsearchQueryFn<GetLatestMonitorDocsParams, Ping>;
5555

5656
getPingHistogram: UMElasticsearchQueryFn<GetPingHistogramParams, HistogramResult>;
57-
58-
/**
59-
* Gets data used for a composite histogram for the currently-running monitors.
60-
*/
61-
getDocCount: UMElasticsearchQueryFn<{}, DocCount>;
6257
}
6358

6459
export interface HistogramQueryResult {

0 commit comments

Comments
 (0)