From 957957e62a67406c81d375c983fbbefdef0a767a Mon Sep 17 00:00:00 2001 From: ismail simsek Date: Fri, 21 Jun 2024 12:39:42 +0200 Subject: [PATCH] Chore: Move amendTimeSeries in @grafana/data package (#89456) * move amendTimeSeries in @grafana/data package * betterer and prettier --- .betterer.results | 16 ++++++++-------- packages/grafana-data/src/index.ts | 1 + .../src/table}/amendTimeSeries.test.ts | 2 +- .../grafana-data/src/table}/amendTimeSeries.ts | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) rename {public/app/features/live/data => packages/grafana-data/src/table}/amendTimeSeries.test.ts (98%) rename {public/app/features/live/data => packages/grafana-data/src/table}/amendTimeSeries.ts (96%) diff --git a/.betterer.results b/.betterer.results index ec2f803ce93..fbe38508f3d 100644 --- a/.betterer.results +++ b/.betterer.results @@ -143,6 +143,14 @@ exports[`better eslint`] = { "packages/grafana-data/src/panel/registryFactories.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], + "packages/grafana-data/src/table/amendTimeSeries.ts:5381": [ + [0, 0, 0, "Unexpected any. Specify a different type.", "0"], + [0, 0, 0, "Do not use any type assertions.", "1"], + [0, 0, 0, "Do not use any type assertions.", "2"], + [0, 0, 0, "Do not use any type assertions.", "3"], + [0, 0, 0, "Do not use any type assertions.", "4"], + [0, 0, 0, "Do not use any type assertions.", "5"] + ], "packages/grafana-data/src/themes/colorManipulator.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -4611,14 +4619,6 @@ exports[`better eslint`] = { [0, 0, 0, "No untranslated strings. Wrap text with ", "1"], [0, 0, 0, "No untranslated strings. Wrap text with ", "2"] ], - "public/app/features/live/data/amendTimeSeries.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Do not use any type assertions.", "1"], - [0, 0, 0, "Do not use any type assertions.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Do not use any type assertions.", "5"] - ], "public/app/features/logs/components/InfiniteScroll.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"] ], diff --git a/packages/grafana-data/src/index.ts b/packages/grafana-data/src/index.ts index bbe35a8fbe1..8ce1be9fe18 100644 --- a/packages/grafana-data/src/index.ts +++ b/packages/grafana-data/src/index.ts @@ -16,6 +16,7 @@ export * from './themes'; export * from './monaco'; export * from './geo/layer'; export * from './query'; +export { amendTable, trimTable, type Table } from './table/amendTimeSeries'; export { type ValueMatcherOptions, type BasicValueMatcherOptions, diff --git a/public/app/features/live/data/amendTimeSeries.test.ts b/packages/grafana-data/src/table/amendTimeSeries.test.ts similarity index 98% rename from public/app/features/live/data/amendTimeSeries.test.ts rename to packages/grafana-data/src/table/amendTimeSeries.test.ts index fce39e371da..4e49bf7df53 100644 --- a/public/app/features/live/data/amendTimeSeries.test.ts +++ b/packages/grafana-data/src/table/amendTimeSeries.test.ts @@ -1,4 +1,4 @@ -import { Table, amendTable } from "./amendTimeSeries"; +import { Table, amendTable } from './amendTimeSeries'; describe('amendTable', () => { it('should append nextTable when there is no overlap (nextTable after prevTable)', () => { diff --git a/public/app/features/live/data/amendTimeSeries.ts b/packages/grafana-data/src/table/amendTimeSeries.ts similarity index 96% rename from public/app/features/live/data/amendTimeSeries.ts rename to packages/grafana-data/src/table/amendTimeSeries.ts index bdc6c2e13dc..4eb35d0a6cf 100644 --- a/public/app/features/live/data/amendTimeSeries.ts +++ b/packages/grafana-data/src/table/amendTimeSeries.ts @@ -1,4 +1,4 @@ -import { closestIdx } from '@grafana/data'; +import { closestIdx } from '../'; export type Table = [times: number[], ...values: any[][]]; @@ -98,7 +98,7 @@ export function trimTable(table: Table, fromTime: number, toTime: number): Table if (fromIdx != null || toIdx != null) { times = times.slice(fromIdx ?? 0, toIdx); - vals = vals.map(vals2 => vals2.slice(fromIdx ?? 0, toIdx)); + vals = vals.map((vals2) => vals2.slice(fromIdx ?? 0, toIdx)); } return [times, ...vals];