mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 21:48:58 +08:00
fix: send float number in args array in case of timeshift formula
This commit is contained in:
parent
ef3a9adb48
commit
3ca2fff5c5
@ -13,6 +13,7 @@ import {
|
|||||||
import { DataSource, QueryFunctionsTypes } from 'types/common/queryBuilder';
|
import { DataSource, QueryFunctionsTypes } from 'types/common/queryBuilder';
|
||||||
|
|
||||||
import Function from './Function';
|
import Function from './Function';
|
||||||
|
import { toFloat64 } from './utils';
|
||||||
|
|
||||||
const defaultMetricFunctionStruct: QueryFunctionProps = {
|
const defaultMetricFunctionStruct: QueryFunctionProps = {
|
||||||
name: QueryFunctionsTypes.CUTOFF_MIN,
|
name: QueryFunctionsTypes.CUTOFF_MIN,
|
||||||
@ -158,7 +159,13 @@ export default function QueryFunctions({
|
|||||||
const updateFunctions = cloneDeep(functions);
|
const updateFunctions = cloneDeep(functions);
|
||||||
|
|
||||||
if (updateFunctions && updateFunctions.length > 0 && updateFunctions[index]) {
|
if (updateFunctions && updateFunctions.length > 0 && updateFunctions[index]) {
|
||||||
updateFunctions[index].args = [value];
|
updateFunctions[index].args = [
|
||||||
|
// timeShift expects a float64 value, so we convert the string to a number
|
||||||
|
// For other functions, we keep the value as a string
|
||||||
|
updateFunctions[index].name === QueryFunctionsTypes.TIME_SHIFT
|
||||||
|
? toFloat64(value)
|
||||||
|
: value,
|
||||||
|
];
|
||||||
setFunctions(updateFunctions);
|
setFunctions(updateFunctions);
|
||||||
onChange(updateFunctions);
|
onChange(updateFunctions);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
export const toFloat64 = (value: string): number => {
|
||||||
|
const parsed = parseFloat(value);
|
||||||
|
if (!Number.isFinite(parsed)) {
|
||||||
|
console.error(`Invalid value for timeshift. value: ${value}`);
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
|
};
|
@ -49,7 +49,7 @@ export type OrderByPayload = {
|
|||||||
|
|
||||||
export interface QueryFunctionProps {
|
export interface QueryFunctionProps {
|
||||||
name: string;
|
name: string;
|
||||||
args: string[];
|
args: (string | number)[];
|
||||||
namedArgs?: Record<string, any>;
|
namedArgs?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user