/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components/MetricChart/getChartData.ts
26 строк
790 B
Anton Standrik
chore!: split apis (#1718)
28 ноя 2024, 12:43
Не верифицирован
28 ноя 2024, 12:43
e050bd7
Код
Авторство
О чём код?
import {TIMEFRAMES} from '../../utils/timeframes'; import type {TimeFrame} from '../../utils/timeframes'; import type {MetricDescription} from './types'; export interface GetChartDataParams { database: string; metrics: MetricDescription[]; timeFrame: TimeFrame; maxDataPoints: number; } export const getChartData = async ( {database, metrics, timeFrame, maxDataPoints}: GetChartDataParams, {signal}: {signal?: AbortSignal} = {}, ) => { const targetString = metrics.map((metric) => `target=${metric.target}`).join('&'); const until = Math.round(Date.now() / 1000); const from = until - TIMEFRAMES[timeFrame]; return window.api.viewer.getChartData( {target: targetString, from, until, maxDataPoints, database}, {signal}, ); };