Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSVB] [Regression] Fix Top Hit / Filter Ratio aggregations #96288

Merged
merged 3 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function CalculationAgg(props) {
CalculationAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function CumulativeSumAgg(props) {
CumulativeSumAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const DerivativeAgg = (props) => {
DerivativeAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FieldSelect } from './field_select';
import { AggRow } from './agg_row';
import { createChangeHandler } from '../lib/create_change_handler';
import { createSelectHandler } from '../lib/create_select_handler';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

import {
htmlIdGenerator,
Expand All @@ -29,7 +30,7 @@ import { getDataStart } from '../../../services';
import { QueryBarWrapper } from '../query_bar_wrapper';

const isFieldHistogram = (fields, indexPattern, field) => {
const indexFields = fields[indexPattern];
const indexFields = fields[getIndexPatternKey(indexPattern)];
if (!indexFields) return false;
const fieldObject = indexFields.find((f) => f.name === field);
if (!fieldObject) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function MathAgg(props) {
MathAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export const MovingAverageAgg = (props) => {
MovingAverageAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const PositiveOnlyAgg = (props) => {
PositiveOnlyAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const SerialDiffAgg = (props) => {
SerialDiffAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const StandardSiblingAggUi = (props) => {
StandardSiblingAggUi.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { KBN_FIELD_TYPES } from '../../../../../../plugins/data/public';
import { PANEL_TYPES } from '../../../../common/panel_types';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

const isFieldTypeEnabled = (fieldRestrictions, fieldType) =>
fieldRestrictions.length ? fieldRestrictions.includes(fieldType) : true;
Expand Down Expand Up @@ -115,8 +116,8 @@ const TopHitAggUi = (props) => {
const handleChange = createChangeHandler(props.onChange, model);
const handleSelectChange = createSelectHandler(handleChange);
const handleTextChange = createTextHandler(handleChange);

const field = fields[indexPattern].find((f) => f.name === model.field);
const fieldsSelector = getIndexPatternKey(indexPattern);
const field = fields[fieldsSelector].find((f) => f.name === model.field);
const aggWithOptions = getAggWithOptions(field, aggWithOptionsRestrictFields);
const orderOptions = getOrderOptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CalculationVars.defaultProps = {

CalculationVars.propTypes = {
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
metrics: PropTypes.array,
model: PropTypes.object,
name: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ SplitByTermsUI.propTypes = {
intl: PropTypes.object,
model: PropTypes.object,
onChange: PropTypes.func,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
fields: PropTypes.object,
uiRestrictions: PropTypes.object,
seriesQuantity: PropTypes.object,
Expand Down