Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Jul 21, 2021
1 parent 94a5aa4 commit bc475a5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/plugins/vis_type_timeseries/common/types/vis_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface PanelData {
error?: string;
}

export type PanelDataArray = [number | undefined, number | string | null];
export type PanelDataArray = [number | undefined | string, number | string | null];

export interface Annotation {
key: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ export const getInterval = (visData: TimeseriesVisData, model: TimeseriesVisPara
) as PanelData[];

return series.reduce((currentInterval, item) => {
if (item.data.length > 1) {
const seriesInterval = item.data[1][0]! - item.data[0][0]!;
if (
item.data.length > 1 &&
typeof item.data[1][0] === 'number' &&
typeof item.data[0][0] === 'number'
) {
const seriesInterval = item.data[1][0] - item.data[0][0];
if (!currentInterval || seriesInterval < currentInterval) return seriesInterval;
}
return currentInterval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ interface SplittedData<TMeta extends BaseMeta = BaseMeta> {
color: string;
meta: TMeta;
timeseries: {
buckets: Array<Record<string, unknown> & { key: string }>;
buckets: [
{
[s: string]: {
// should be typed
values: Record<string, unknown>;
};
} & { key: string | number }
];
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
import { getAggValue } from './get_agg_value';
import { METRIC_TYPES } from '../../../../../data/common';
import type { Metric } from '../../../../common/types';
import type { PanelDataArray } from '../../../../common/types/vis_data';

export const mapEmptyToZero = (
metric: Metric,
buckets: Array<
{
key: number;
key: number | string;
} & Record<string, unknown>
>
) => {
): PanelDataArray[] => {
// Metric types where an empty set equals `zero`
const isSettableToZero = [
METRIC_TYPES.COUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function getLastSeriesTimestamp(seriesGroup: Array<PanelSeries['series']>
if (lastValue) {
const [dataLastTimestamp] = lastValue;

if (typeof dataLastTimestamp !== 'undefined') {
if (typeof dataLastTimestamp === 'number') {
lastTimestamp = Math.max(dataLastTimestamp, lastTimestamp ?? dataLastTimestamp);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { toPercentileNumber } from '../../../../../common/to_percentile_number';
import { METRIC_TYPES } from '../../../../../common/enums';

import type { TableResponseProcessorsFunction } from './types';
import { PanelDataArray } from '../../../../../common/types/vis_data';
import type { PanelDataArray } from '../../../../../common/types/vis_data';

export const percentile: TableResponseProcessorsFunction = ({
bucket,
Expand All @@ -36,7 +36,7 @@ export const percentile: TableResponseProcessorsFunction = ({
const lastPercentile = last(metric.percentiles)?.value ?? 0;
const percentileKey = toPercentileNumber(lastPercentile);
const data = split.timeseries.buckets.map((b) => [
Number(b.key),
b.key,
b[metric.id].values[percentileKey],
]) as PanelDataArray[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { toPercentileNumber } from '../../../../../common/to_percentile_number';
import { METRIC_TYPES } from '../../../../../common/enums';

import type { TableResponseProcessorsFunction } from './types';
import { PanelDataArray } from '../../../../../common/types/vis_data';
import type { PanelDataArray } from '../../../../../common/types/vis_data';

export const percentileRank: TableResponseProcessorsFunction = ({
bucket,
Expand All @@ -37,7 +37,7 @@ export const percentileRank: TableResponseProcessorsFunction = ({
const lastPercentileNumber = toPercentileNumber(lastRankValue);

const data = split.timeseries.buckets.map((b) => [
Number(b.key),
b.key,
getAggValue(b, {
...metric,
value: lastPercentileNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const stdSibling: TableResponseProcessorsFunction = ({
const fakeResp = { aggregations: bucket };
(await getSplits(fakeResp, panel, series, meta, extractFields)).forEach((split) => {
const data: PanelDataArray[] = split.timeseries.buckets.map((b) => {
return [Number(b.key), getSiblingAggValue(split, metric)];
return [b.key, getSiblingAggValue(split, metric)];
});

results.push({
Expand Down

0 comments on commit bc475a5

Please sign in to comment.