mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 20:52:02 +08:00
feat: pass fill gaps to query range api (#5276)
This commit is contained in:
parent
6ee9705599
commit
adfeaaa1f0
@ -108,6 +108,7 @@ function GridCardGraph({
|
|||||||
query: updatedQuery,
|
query: updatedQuery,
|
||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
variables: getDashboardVariables(variables),
|
variables: getDashboardVariables(variables),
|
||||||
|
fillGaps: widget.fillSpans,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
updatedQuery.builder.queryData[0].pageSize = 10;
|
updatedQuery.builder.queryData[0].pageSize = 10;
|
||||||
@ -122,6 +123,7 @@ function GridCardGraph({
|
|||||||
limit: updatedQuery.builder.queryData[0].limit || 0,
|
limit: updatedQuery.builder.queryData[0].limit || 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
fillGaps: widget.fillSpans,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,6 +154,7 @@ function GridCardGraph({
|
|||||||
widget?.query,
|
widget?.query,
|
||||||
widget?.panelTypes,
|
widget?.panelTypes,
|
||||||
widget.timePreferance,
|
widget.timePreferance,
|
||||||
|
widget.fillSpans,
|
||||||
requestData,
|
requestData,
|
||||||
],
|
],
|
||||||
retry(failureCount, error): boolean {
|
retry(failureCount, error): boolean {
|
||||||
|
@ -72,10 +72,16 @@ function LeftContainer({
|
|||||||
globalSelectedInterval,
|
globalSelectedInterval,
|
||||||
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
|
graphType: getGraphType(selectedGraph || selectedWidget.panelTypes),
|
||||||
query: stagedQuery,
|
query: stagedQuery,
|
||||||
|
fillGaps: selectedWidget.fillSpans || false,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [stagedQuery, selectedTime, globalSelectedInterval]);
|
}, [
|
||||||
|
stagedQuery,
|
||||||
|
selectedTime,
|
||||||
|
selectedWidget.fillSpans,
|
||||||
|
globalSelectedInterval,
|
||||||
|
]);
|
||||||
|
|
||||||
const queryResponse = useGetQueryRange(
|
const queryResponse = useGetQueryRange(
|
||||||
requestData,
|
requestData,
|
||||||
|
@ -75,6 +75,7 @@ export interface GetQueryResultsProps {
|
|||||||
globalSelectedInterval: Time | TimeV2 | CustomTimeType;
|
globalSelectedInterval: Time | TimeV2 | CustomTimeType;
|
||||||
variables?: Record<string, unknown>;
|
variables?: Record<string, unknown>;
|
||||||
params?: Record<string, unknown>;
|
params?: Record<string, unknown>;
|
||||||
|
fillGaps?: boolean;
|
||||||
tableParams?: {
|
tableParams?: {
|
||||||
pagination?: Pagination;
|
pagination?: Pagination;
|
||||||
selectColumns?: any;
|
selectColumns?: any;
|
||||||
|
@ -20,6 +20,7 @@ export const prepareQueryRangePayload = ({
|
|||||||
tableParams,
|
tableParams,
|
||||||
variables = {},
|
variables = {},
|
||||||
params = {},
|
params = {},
|
||||||
|
fillGaps = false,
|
||||||
}: GetQueryResultsProps): PrepareQueryRangePayload => {
|
}: GetQueryResultsProps): PrepareQueryRangePayload => {
|
||||||
let legendMap: Record<string, string> = {};
|
let legendMap: Record<string, string> = {};
|
||||||
const { allowSelectedIntervalForStepGen, ...restParams } = params;
|
const { allowSelectedIntervalForStepGen, ...restParams } = params;
|
||||||
@ -27,6 +28,7 @@ export const prepareQueryRangePayload = ({
|
|||||||
const compositeQuery: QueryRangePayload['compositeQuery'] = {
|
const compositeQuery: QueryRangePayload['compositeQuery'] = {
|
||||||
queryType: query.queryType,
|
queryType: query.queryType,
|
||||||
panelType: graphType,
|
panelType: graphType,
|
||||||
|
fillGaps,
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (query.queryType) {
|
switch (query.queryType) {
|
||||||
|
@ -17,11 +17,7 @@ function getXAxisTimestamps(seriesList: QueryData[]): number[] {
|
|||||||
return timestampsArr.sort((a, b) => a - b);
|
return timestampsArr.sort((a, b) => a - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillMissingXAxisTimestamps(
|
function fillMissingXAxisTimestamps(timestampArr: number[], data: any[]): any {
|
||||||
timestampArr: number[],
|
|
||||||
data: any[],
|
|
||||||
fillSpans: boolean,
|
|
||||||
): any {
|
|
||||||
// Generate a set of all timestamps in the range
|
// Generate a set of all timestamps in the range
|
||||||
const allTimestampsSet = new Set(timestampArr);
|
const allTimestampsSet = new Set(timestampArr);
|
||||||
const processedData = JSON.parse(JSON.stringify(data));
|
const processedData = JSON.parse(JSON.stringify(data));
|
||||||
@ -35,14 +31,14 @@ function fillMissingXAxisTimestamps(
|
|||||||
);
|
);
|
||||||
|
|
||||||
missingTimestamps.forEach((timestamp) => {
|
missingTimestamps.forEach((timestamp) => {
|
||||||
const value = fillSpans ? 0 : null;
|
const value = null;
|
||||||
|
|
||||||
entry.values.push([timestamp, value]);
|
entry.values.push([timestamp, value]);
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.values.forEach((v) => {
|
entry.values.forEach((v) => {
|
||||||
if (Number.isNaN(v[1])) {
|
if (Number.isNaN(v[1])) {
|
||||||
const replaceValue = fillSpans ? 0 : null;
|
const replaceValue = null;
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
v[1] = replaceValue;
|
v[1] = replaceValue;
|
||||||
} else if (v[1] !== null) {
|
} else if (v[1] !== null) {
|
||||||
@ -85,11 +81,7 @@ export const getUPlotChartData = (
|
|||||||
): any[] => {
|
): any[] => {
|
||||||
const seriesList = apiResponse?.data?.result || [];
|
const seriesList = apiResponse?.data?.result || [];
|
||||||
const timestampArr = getXAxisTimestamps(seriesList);
|
const timestampArr = getXAxisTimestamps(seriesList);
|
||||||
const yAxisValuesArr = fillMissingXAxisTimestamps(
|
const yAxisValuesArr = fillMissingXAxisTimestamps(timestampArr, seriesList);
|
||||||
timestampArr,
|
|
||||||
seriesList,
|
|
||||||
fillSpans || false,
|
|
||||||
);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
timestampArr,
|
timestampArr,
|
||||||
|
@ -18,6 +18,7 @@ export type QueryRangePayload = {
|
|||||||
promQueries?: Record<string, IPromQLQuery>;
|
promQueries?: Record<string, IPromQLQuery>;
|
||||||
queryType: EQueryType;
|
queryType: EQueryType;
|
||||||
panelType: PANEL_TYPES;
|
panelType: PANEL_TYPES;
|
||||||
|
fillGaps?: boolean;
|
||||||
};
|
};
|
||||||
end: number;
|
end: number;
|
||||||
start: number;
|
start: number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user