Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: table row data doesn't align with the response #5248

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions frontend/src/lib/query/createTableColumnsFromQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ const fillRestAggregationData = (
queryTableData: QueryDataV3[],
seria: SeriesItem,
equalQueriesByLabels: string[],
isEqualQuery: boolean,
): void => {
const nextQueryData =
queryTableData.find((q) => q.queryName === column.field) || null;
Expand All @@ -374,13 +375,13 @@ const fillRestAggregationData = (
nextQueryData,
);

const isEqual = isEqualQueriesByLabel(equalQueriesByLabels, column.field);
if (targetSeria) {
const isEqual = isEqualQueriesByLabel(equalQueriesByLabels, column.field);
if (!isEqual) {
// This line is crucial. It ensures that no additional rows are added to the table for similar labels across all formulas here is how this check is applied: signoz/frontend/src/lib/query/createTableColumnsFromQuery.ts line number 370
equalQueriesByLabels.push(column.field);
}
} else {
} else if (!isEqualQuery) {
column.data.push('N/A');
}
};
Expand Down Expand Up @@ -435,6 +436,7 @@ const fillDataFromSeries = (
queryTableData,
seria,
equalQueriesByLabels,
isEqualQuery,
);

return;
Expand Down Expand Up @@ -570,6 +572,29 @@ export const createTableColumnsFromQuery: CreateTableDataFromQuery = ({
a.queryName < b.queryName ? -1 : 1,
);

// the reason we need this is because the filling of values in rows doesn't account for mismatch enteries
// in the response. Example : Series A -> [label1, label2] and Series B -> [label2,label1] this isn't accounted for
sortedQueryTableData.forEach((q) => {
vikrantgupta25 marked this conversation as resolved.
Show resolved Hide resolved
q.series?.forEach((s) => {
s.labelsArray?.sort((a, b) =>
Object.keys(a)[0] < Object.keys(b)[0] ? -1 : 1,
);
});
q.series?.sort((a, b) => {
let labelA = '';
let labelB = '';
a.labelsArray.forEach((lab) => {
labelA += Object.values(lab)[0];
});

b.labelsArray.forEach((lab) => {
labelB += Object.values(lab)[0];
});

return labelA < labelB ? -1 : 1;
});
});

const dynamicColumns = getDynamicColumns(sortedQueryTableData, query);

const { filledDynamicColumns, rowsLength } = fillColumnsData(
Expand Down
Loading