Skip to content

Commit 1a915cb

Browse files
authored
[ML] Data Frames: Update stats data structure. (#42117) (#42147)
Fixes UI regressions caused by breaking API changes.
1 parent 5e0dae4 commit 1a915cb

File tree

19 files changed

+222
-160
lines changed

19 files changed

+222
-160
lines changed

x-pack/legacy/plugins/ml/public/data_frame/pages/data_frame_new_pivot/components/source_index_preview/expanded_row.tsx

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

7-
import { get } from 'lodash';
8-
97
import React from 'react';
108

119
import { EuiBadge, EuiText } from '@elastic/eui';
10+
import { idx } from '@kbn/elastic-idx';
1211

1312
import { getSelectableFields, EsDoc } from '../../../../common';
1413

@@ -19,7 +18,8 @@ interface ExpandedRowProps {
1918
export const ExpandedRow: React.SFC<ExpandedRowProps> = ({ item }) => {
2019
const keys = getSelectableFields([item]);
2120
const list = keys.map(k => {
22-
const value = get(item._source, k, '');
21+
// split the attribute key string and use reduce with an idx check to access nested attributes.
22+
const value = k.split('.').reduce((obj, i) => idx(obj, _ => _[i]), item._source) || '';
2323
return (
2424
<span key={k}>
2525
<EuiBadge>{k}:</EuiBadge>

x-pack/legacy/plugins/ml/public/data_frame/pages/data_frame_new_pivot/components/source_index_preview/use_source_index_data.ts

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

7-
import { get } from 'lodash';
8-
97
import React, { useEffect, useState } from 'react';
108

119
import { SearchResponse } from 'elasticsearch';
1210

11+
import { idx } from '@kbn/elastic-idx';
12+
1313
import { IndexPattern } from 'ui/index_patterns';
1414

1515
import { ml } from '../../../../../services/ml_api_service';
@@ -82,7 +82,7 @@ export const useSourceIndexData = (
8282
[key: string]: any;
8383
};
8484
flattenedFields.forEach(ff => {
85-
item[ff] = get(doc._source, ff);
85+
item[ff] = idx(doc._source, _ => _[ff]);
8686
if (item[ff] === undefined) {
8787
item[ff] = doc._source[`"${ff}"`];
8888
}

x-pack/legacy/plugins/ml/public/data_frame/pages/data_frame_new_pivot/components/step_create/step_create_form.tsx

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

77
import React, { Fragment, SFC, useContext, useEffect, useState } from 'react';
8+
import { idx } from '@kbn/elastic-idx';
89
import { i18n } from '@kbn/i18n';
910
import { toastNotifications } from 'ui/notify';
1011

@@ -191,7 +192,12 @@ export const StepCreateForm: SFC<Props> = React.memo(
191192
try {
192193
const stats = await ml.dataFrame.getDataFrameTransformsStats(transformId);
193194
if (stats && Array.isArray(stats.transforms) && stats.transforms.length > 0) {
194-
const percent = Math.round(stats.transforms[0].state.progress.percent_complete);
195+
const percent = Math.round(
196+
idx(
197+
stats,
198+
_ => _.transforms[0].checkpointing.next.checkpoint_progress.percent_complete
199+
) || 0
200+
);
195201
setProgressPercentComplete(percent);
196202
if (percent >= 100) {
197203
clearInterval(interval);

x-pack/legacy/plugins/ml/public/data_frame/pages/transform_management/components/transform_list/__mocks__/data_frame_transform_list_row.json

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,66 @@
22
"config": {
33
"id": "fq_date_histogram_1m_1441",
44
"source": { "index": ["farequote-2019"], "query": { "match_all": {} } },
5-
"dest": { "index": "fq_data_histogram_1m_1441" },
5+
"dest": { "index": "fq_date_histogram_1m_1441" },
66
"pivot": {
77
"group_by": {
8-
"date_histogram(@timestamp)": {
9-
"date_histogram": { "field": "@timestamp", "interval": "1m" }
8+
"@timestamp": {
9+
"date_histogram": { "field": "@timestamp", "calendar_interval": "1m" }
1010
}
1111
},
12-
"aggregations": { "avg(response)": { "avg": { "field": "responsetime" } } }
13-
}
12+
"aggregations": { "responsetime.avg": { "avg": { "field": "responsetime" } } }
13+
},
14+
"version": "8.0.0",
15+
"create_time": 1564388146667,
16+
"mode": "batch"
1417
},
1518
"id": "fq_date_histogram_1m_1441",
16-
"state": {
17-
"task_state": "stopped",
18-
"indexer_state": "stopped",
19-
"current_position": { "date_histogram(@timestamp)": 1549929540000 },
20-
"checkpoint": 1
21-
},
22-
"stats": {
23-
"pages_processed": 0,
24-
"documents_processed": 0,
25-
"documents_indexed": 0,
26-
"trigger_count": 0,
27-
"index_time_in_ms": 0,
28-
"index_total": 0,
29-
"index_failures": 0,
30-
"search_time_in_ms": 0,
31-
"search_total": 0,
32-
"search_failures": 0
33-
},
3419
"checkpointing": {
35-
"current": {
36-
"timestamp": "2019-06-28T16:09:23.539Z",
37-
"timestamp_millis": 1561738163539,
38-
"time_upper_bound": "2019-06-28T16:09:13.539Z",
39-
"time_upper_bound_millis": 1561738153539
20+
"last": {
21+
"checkpoint": 1,
22+
"timestamp_millis": 1564388281199
23+
},
24+
"next": {
25+
"checkpoint": 2,
26+
"indexer_state": "stopped",
27+
"checkpoint_progress": {
28+
"total_docs": 86274,
29+
"docs_remaining": 0,
30+
"percent_complete": 100
31+
}
4032
},
4133
"operations_behind": 0
34+
},
35+
"stats": {
36+
"id": "fq_date_histogram_1m_1441",
37+
"task_state": "stopped",
38+
"stats": {
39+
"pages_processed": 16,
40+
"documents_processed": 86274,
41+
"documents_indexed": 7200,
42+
"trigger_count": 1,
43+
"index_time_in_ms": 1310,
44+
"index_total": 15,
45+
"index_failures": 0,
46+
"search_time_in_ms": 463,
47+
"search_total": 16,
48+
"search_failures": 0
49+
},
50+
"checkpointing": {
51+
"last": {
52+
"checkpoint": 1,
53+
"timestamp_millis": 1564388281199
54+
},
55+
"next": {
56+
"checkpoint": 2,
57+
"indexer_state": "stopped",
58+
"checkpoint_progress": {
59+
"total_docs": 86274,
60+
"docs_remaining": 0,
61+
"percent_complete": 100
62+
}
63+
},
64+
"operations_behind": 0
65+
}
4266
}
4367
}

0 commit comments

Comments
 (0)