Skip to content

Commit

Permalink
Merge branch 'actions/remove-cleanup-task' of github.com:mikecote/kib…
Browse files Browse the repository at this point in the history
…ana into actions/remove-cleanup-task
  • Loading branch information
mikecote committed Mar 27, 2023
2 parents cfcbd61 + 69d683d commit 01b5055
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
*/
import { Datatable, DatatableColumn } from '@kbn/expressions-plugin/public';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { getFilterClickData, getFilterEventData, getFilterPopoverTitle } from './filter_helpers';
import {
getFilterClickData,
getFilterEventData,
getFilterPopoverTitle,
getAccessor,
} from './filter_helpers';
import { createMockBucketColumns, createMockVisData, createMockPieParams } from '../mocks';
import { consolidateMetricColumns } from '../../common/utils';
import { LayerValue } from '@elastic/charts';
Expand Down Expand Up @@ -267,6 +272,26 @@ describe('getFilterEventData', () => {
});
});

describe('getAccessor', () => {
it('returns the correct accessor for ExpressionValueVisDimension', () => {
const accessor = getAccessor(visParams.dimensions.buckets, 2);
expect(accessor).toStrictEqual({
accessor: 2,
format: {
id: 'terms',
params: { id: 'boolean', missingBucketLabel: 'Missing', otherBucketLabel: 'Other' },
},
type: 'vis_dimension',
});
});

it('returns the correct accessor for strings', () => {
const buckets = ['bucket1', 'bucket2'];
const accessor = getAccessor(buckets, 0);
expect(accessor).toStrictEqual('bucket1');
});
});

describe('getFilterPopoverTitle', () => {
it('returns the series key if no buckets', () => {
const series = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { ValueClickContext } from '@kbn/embeddable-plugin/public';
import { getFormatByAccessor } from '@kbn/visualizations-plugin/common/utils';
import type { FieldFormat, FormatFactory } from '@kbn/field-formats-plugin/common';
import { BucketColumns, PartitionVisParams } from '../../common/types';
import { BucketColumns, PartitionVisParams, Dimensions } from '../../common/types';
import { FilterEvent } from '../types';

export const canFilter = async (
Expand Down Expand Up @@ -131,6 +131,13 @@ export const getSeriesValueColumnIndex = (value: string, visData: Datatable): nu
return visData.columns.findIndex(({ id }) => !!visData.rows.find((r) => r[id] === value));
};

export const getAccessor = (buckets: Dimensions['buckets'], index: number) => {
const accessorForDimensionBuckets = buckets?.find((b) => {
return typeof b !== 'string' && b.accessor === index;
});
return accessorForDimensionBuckets || buckets?.[index];
};

export const getFilterPopoverTitle = (
visParams: PartitionVisParams,
visData: Datatable,
Expand All @@ -140,7 +147,7 @@ export const getFilterPopoverTitle = (
) => {
let formattedTitle = '';
if (visParams.dimensions.buckets) {
const accessor = visParams.dimensions.buckets[columnIndex];
const accessor = getAccessor(visParams.dimensions.buckets, columnIndex);
formattedTitle = accessor
? formatter(getFormatByAccessor(accessor, visData.columns)).convert(seriesKey)
: '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,18 @@ export const LinksMenuUI = (props: LinksMenuProps) => {
// Start from the previous hour.
earliestMoment.subtract(1, 'h');
}
let latestMoment = moment(record.timestamp).add(record.bucket_span, 's');

const latestMoment = moment(record.timestamp).add(record.bucket_span, 's');
if (props.isAggregatedData === true) {
latestMoment = moment(record.timestamp).endOf(interval);
if (interval === 'hour') {
// Show to the end of the next hour.
latestMoment.add(1, 'h'); // e.g. 2016-02-08T18:59:59.999Z
latestMoment.add(1, 'h');
}
latestMoment.subtract(1, 'ms').endOf(interval); // e.g. 2016-02-08T18:59:59.999Z
}

const from = timeFormatter(earliestMoment.unix() * 1000); // e.g. 2016-02-08T16:00:00.000Z
const to = timeFormatter(latestMoment.unix() * 1000);
const to = timeFormatter(latestMoment.unix() * 1000); // e.g. 2016-02-08T18:59:59.000Z

let kqlQuery = '';

Expand Down Expand Up @@ -315,16 +317,16 @@ export const LinksMenuUI = (props: LinksMenuProps) => {
}

if (configuredUrlValue.includes('$latest$')) {
let latestMoment = moment(timestamp).add(record.bucket_span, 's');
const latestMoment = moment(timestamp).add(record.bucket_span, 's');
if (timeRangeInterval !== null) {
latestMoment.add(timeRangeInterval);
} else {
if (isAggregatedData === true) {
latestMoment = moment(timestamp).endOf(interval);
if (interval === 'hour') {
// Show to the end of the next hour.
latestMoment.add(1, 'h'); // e.g. 2016-02-08T18:59:59.999Z
}
latestMoment.subtract(1, 'ms').endOf(interval); // e.g. 2016-02-08T18:59:59.999Z
}
}
record.latest = latestMoment.toISOString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export default function ({ getService }: FtrProviderContext) {
const ml = getService('ml');
const editedDescription = 'Edited description';

describe('classification creation', function () {
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/153798
describe.skip('classification creation', function () {
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/bm_classification');
await ml.testResources.createIndexPatternIfNeeded('ft_bank_marketing');
Expand Down

0 comments on commit 01b5055

Please sign in to comment.