Skip to content

Commit

Permalink
Fix a bug where failing to start filtering by current value after the…
Browse files Browse the repository at this point in the history
… column results are re-ordered (#2483)
  • Loading branch information
YannanGao-gs authored Aug 9, 2023
1 parent f20b01c commit 61ee843
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changeset/five-pants-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
'@finos/legend-graph': patch
---
5 changes: 5 additions & 0 deletions .changeset/shy-oranges-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-query-builder': patch
---

Fix a bug where failing to start filtering by current value after the column results are re-ordered
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { uuid } from '@finos/legend-shared';
import { guaranteeNonNullable, uuid } from '@finos/legend-shared';

// Core
export enum BuilderType {
Expand Down Expand Up @@ -138,3 +138,19 @@ export class ClassExecutionResult extends ExecutionResult {
override builder = new ClassBuilder(BuilderType.CLASS_BUILDER);
objects!: object;
}

export const getTDSRowRankByColumnInAsc = (
a: TDSRow,
b: TDSRow,
colIndex: number,
): number => {
const a1 =
a.values[colIndex] === null || a.values[colIndex] === undefined
? -Infinity
: a.values[colIndex];
const b1 =
b.values[colIndex] === null || b.values[colIndex] === undefined
? -Infinity
: b.values[colIndex];
return Number(guaranteeNonNullable(a1)) - Number(guaranteeNonNullable(b1));
};
1 change: 1 addition & 0 deletions packages/legend-graph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export {
TDSExecutionResult as TDSExecutionResult,
RawExecutionResult,
EXECUTION_SERIALIZATION_FORMAT,
getTDSRowRankByColumnInAsc,
} from './graph-manager/action/execution/ExecutionResult.js';
export { ExternalFormatDescription } from './graph-manager/action/externalFormat/ExternalFormatDescription.js';
export * from './graph-manager/action/generation/ArtifactGenerationExtensionResult.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
EnumValueInstanceValue,
EnumValueExplicitReference,
RelationalExecutionActivities,
getTDSRowRankByColumnInAsc,
} from '@finos/legend-graph';
import {
ActionAlertActionType,
Expand Down Expand Up @@ -523,10 +524,19 @@ const QueryResultCellRenderer = observer(
) {
return undefined;
}

return resultState.executionResult.result.rows[rowIndex]?.values[
colIndex
const sortedExecutionResult = [
...resultState.executionResult.result.rows,
];
if (params.columnApi.getColumnState()[colIndex]?.sort === 'asc') {
sortedExecutionResult.sort((a, b) =>
getTDSRowRankByColumnInAsc(a, b, colIndex),
);
} else if (params.columnApi.getColumnState()[colIndex]?.sort === 'desc') {
sortedExecutionResult.sort((a, b) =>
getTDSRowRankByColumnInAsc(b, a, colIndex),
);
}
return sortedExecutionResult[rowIndex]?.values[colIndex];
};

const isCoordinatesSelected = (
Expand Down

0 comments on commit 61ee843

Please sign in to comment.