Skip to content

Commit

Permalink
[ML] Fix annotation table in job list not having terms
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jul 9, 2020
1 parent aa98817 commit 02024e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/ml/common/constants/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export const ANNOTATION_USER_UNKNOWN = '<user unknown>';
export const ANNOTATION_MAX_LENGTH_CHARS = 1000;

export const ANNOTATION_EVENT_USER = 'user';
export const ANNOTATION_EVENT_DELAYED_DATA = 'delayed_data';
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class AnnotationsTable extends Component {
super(props);
this.state = {
annotations: [],
aggregations: null,
isLoading: false,
queryText: `event:(${ANNOTATION_EVENT_USER} or ${ANNOTATION_EVENT_DELAYED_DATA})`,
searchError: undefined,
Expand Down Expand Up @@ -111,6 +112,7 @@ export class AnnotationsTable extends Component {
.then((resp) => {
this.setState((prevState, props) => ({
annotations: resp.annotations[props.jobs[0].job_id] || [],
aggregations: resp.aggregations,
errorMessage: undefined,
isLoading: false,
jobId: props.jobs[0].job_id,
Expand Down Expand Up @@ -518,8 +520,9 @@ export class AnnotationsTable extends Component {
};
};
let filterOptions = [];
if (this.props.aggregations?.event?.buckets) {
const buckets = this.props.aggregations.event.buckets;
const aggregations = this.props.aggregations ?? this.state.aggregations;
if (aggregations) {
const buckets = aggregations.event.buckets;
const foundUser = buckets.findIndex((d) => d.key === ANNOTATION_EVENT_USER) > -1;
filterOptions = foundUser
? buckets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import {
Annotation,
EsAggregationResult,
FieldToBucket,
GetAnnotationsResponse,
} from '../../../../common/types/annotations';
Expand All @@ -28,19 +27,6 @@ export const annotations = {
body,
});
},
getUniqueAnnotationTerms(obj: {
jobIds: string[];
earliestMs: number;
latestMs: number;
fields: FieldToBucket[];
}) {
const body = JSON.stringify(obj);
return http$<{ annotationTerms: Record<string, EsAggregationResult> }>({
path: `${basePath()}/annotations/terms`,
method: 'POST',
body,
});
},

indexAnnotation(obj: Annotation) {
const body = JSON.stringify(obj);
Expand Down

0 comments on commit 02024e5

Please sign in to comment.