Skip to content

Commit

Permalink
Fixed terms.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Oct 27, 2022
1 parent 7eb9001 commit a53dd45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('convertToRangeColumn', () => {
params: {
type: RANGE_MODES.Histogram,
maxBars: 'auto',
ranges: [],
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ describe('convertToDateHistogramColumn', () => {
size: 5,
include: [],
exclude: [],
includeIsRegex: false,
excludeIsRegex: false,
parentFormat: { id: 'terms' },
orderBy: { type: 'alphabetical' },
orderDirection: 'asc',
Expand Down Expand Up @@ -139,6 +141,8 @@ describe('convertToDateHistogramColumn', () => {
size: 5,
include: [],
exclude: [],
includeIsRegex: false,
excludeIsRegex: false,
parentFormat: { id: 'terms' },
orderBy: { type: 'column', columnId: metricColumns[0].columnId },
orderAgg: metricColumns[0],
Expand Down Expand Up @@ -228,6 +232,8 @@ describe('convertToDateHistogramColumn', () => {
size: 5,
include: [],
exclude: [],
includeIsRegex: false,
excludeIsRegex: false,
parentFormat: { id: 'terms' },
orderBy: { type: 'custom' },
orderAgg: metricColumns[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const getOrderByWithAgg = ({

const filterOutEmptyValues = (values: string | Array<number | string>): number[] | string[] => {
if (typeof values === 'string') {
return Boolean(values) ? [] : [values];
return Boolean(values) ? [values] : [];
}

return values.filter((v): v is string | number => {
Expand All @@ -99,12 +99,14 @@ export const convertToTermsParams = ({
return null;
}

const exclude = agg.aggParams.exclude ? filterOutEmptyValues(agg.aggParams.exclude) : [];
const include = agg.aggParams.include ? filterOutEmptyValues(agg.aggParams.include) : [];
return {
size: agg.aggParams.size ?? 10,
include: agg.aggParams.include ? filterOutEmptyValues(agg.aggParams.include) : [],
includeIsRegex: agg.aggParams.includeIsRegex,
exclude: agg.aggParams.exclude ? filterOutEmptyValues(agg.aggParams.exclude) : [],
excludeIsRegex: agg.aggParams.excludeIsRegex,
include,
exclude,
includeIsRegex: Boolean(include.length && agg.aggParams.includeIsRegex),
excludeIsRegex: Boolean(exclude.length && agg.aggParams.excludeIsRegex),
otherBucket: agg.aggParams.otherBucket,
orderDirection: agg.aggParams.order?.value ?? 'desc',
parentFormat: { id: 'terms' },
Expand Down

0 comments on commit a53dd45

Please sign in to comment.