SCAL-257337: Added sortOptions to getUnderlyingDataForPoint - #678
tushardeepakts wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces sorting capabilities to the getUnderlyingDataForPoint method in AnswerService by adding a new SortOptions interface, an updateSort GraphQL mutation, and the applySort helper method. Corresponding unit tests have also been added to verify the sorting behavior. The review feedback suggests adding defensive checks within applySort to handle missing or invalid inputs (such as undefined source columns or unrecognized column names) to prevent runtime TypeErrors and improve robustness.
commit: |
| /** | ||
| * Describes how to sort a column when fetching data. Pass an array of these to | ||
| * sort by multiple columns, in priority order. | ||
| * @version SDK: 1.52.0 | ThoughtSpot Cloud: 26.9.0.cl |
There was a problem hiding this comment.
The SDK version I have taken from package.json, and TS cloud version I have calculated from the formula mentioned in Claude.md file :
For SDK 1.N.x the Cloud version is 26.(N-43).0.cl
| private async applySort(sortOptions: SortOptions[], sourceDetail: any) { | ||
| const sortDetails = sortOptions.map((sort) => ({ | ||
| columnId: getGuidsFromColumnNames(sourceDetail, [sort.columnName]).values().next().value, | ||
| sortType: sort.ascending ? 'ASCENDING' : 'DESCENDING', |
There was a problem hiding this comment.
make a enum for this
There was a problem hiding this comment.
These are internal wire-contract values used once in a ternary. An enum here would be unnecessary. The public API only exposes ascending: boolean; ASCENDING/DESCENDING are just internal GraphQL values.
Summary
Adds an optional
sortOptionsparameter so customers can sort the raw underlying data behind a clicked chart point.Changes
SortOptionstype ({ columnName; ascending }), exported fromindex.ts.sortOptionsparameter togetUnderlyingDataForPoint(cols, points?, sortOptions?).updateSortmutation.applySort()helper.Video:
Screen.Recording.2026-09-21.at.2.53.20.PM.mov