kgabryje commented on code in PR #35343:
URL: https://github.com/apache/superset/pull/35343#discussion_r2465302987
##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts:
##########
@@ -211,22 +213,137 @@ const buildQuery: BuildQuery<TableChartFormData> = (
moreProps.row_offset = currentPage * pageSize;
}
- // getting sort by in case of server pagination from own state
let sortByFromOwnState: QueryFormOrderBy[] | undefined;
- if (Array.isArray(ownState?.sortBy) && ownState?.sortBy.length > 0) {
- const sortByItem = ownState?.sortBy[0];
- sortByFromOwnState = [[sortByItem?.key, !sortByItem?.desc]];
+
+ const sortSource =
+ isDownloadQuery && ownState?.sortModel
+ ? ownState.sortModel
+ : ownState?.sortBy;
+
+ if (Array.isArray(sortSource) && sortSource.length > 0) {
+ const mapColIdToIdentifier = (colId: string): string | undefined => {
+ const matchingColumn = columns.find((col: QueryFormColumn) => {
+ if (typeof col === 'string') return col === colId;
+ return col?.sqlExpression === colId || col?.label === colId;
+ });
+
+ if (matchingColumn) {
+ return typeof matchingColumn === 'string'
+ ? matchingColumn
+ : matchingColumn.sqlExpression || matchingColumn.label;
+ }
+
+ const matchingMetric = (metrics || []).find((met: QueryFormMetric) => {
+ if (typeof met === 'string')
+ return met === colId || `%${met}` === colId;
+ const metLabel = getMetricLabel(met);
Review Comment:
I think this could be simplified a bit, as getMetricLabel works with string
metrics too, so the first check might be redundant
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]