Skip to content

Fix chart sorting#16996

Merged
bosiraphael merged 12 commits intomainfrom
r--chart-sorting
Jan 8, 2026
Merged

Fix chart sorting#16996
bosiraphael merged 12 commits intomainfrom
r--chart-sorting

Conversation

@bosiraphael
Copy link
Copy Markdown
Contributor

I introduced a bug in the chart sorting in this PR: #16794
This PR fixes this.

The sorting on the first axis is already done by the group by for FIELD_ASC and FIELD_DESC. It is sorted also for the second axis but in each group.
For instance, if I create a graph that displays the amount of sales on each day of the week grouped by vendor
I can have for:
Monday: Vendor B, Vendor C
Tuesday: Vendor A, Vendor B
Wednesday: Vendor A, Vendor C
...
Inside each day the order of the vendor is correct, but by looking at only one day, I can't know the order of all the vendors.
That is why we always need to sort the second axis.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/twenty-front/src/modules/page-layout/widgets/graph/utils/sortTwoDimensionalChartPrimaryAxisDataByFieldOrManually.ts">

<violation number="1" location="packages/twenty-front/src/modules/page-layout/widgets/graph/utils/sortTwoDimensionalChartPrimaryAxisDataByFieldOrManually.ts:54">
P1: This change will break the existing unit test `should sort by FIELD_ASC` in `sortTwoDimensionalChartPrimaryAxisDataByFieldOrManually.test.ts`. The test expects data to be sorted but the function now returns it unchanged. Either update the test to expect unchanged data (since sorting is done elsewhere per the PR description), or verify the code change is correct.</violation>
</file>

<file name="packages/twenty-front/src/modules/page-layout/widgets/graph/utils/compareDimensionValues.ts">

<violation number="1" location="packages/twenty-front/src/modules/page-layout/widgets/graph/utils/compareDimensionValues.ts:10">
P1: The `parseDate` function can throw if the string is not a valid date format, but it claims to return `null` for invalid inputs. Since this is used in a comparison function for sorting, throwing here would crash the entire sort operation. Wrap the parsing in a try-catch to return `null` on failure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 7, 2026

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:59344

This environment will automatically shut down when the PR is closed or after 5 hours.

@bosiraphael bosiraphael enabled auto-merge January 8, 2026 12:36
Copy link
Copy Markdown
Contributor

@ehconitin ehconitin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bosiraphael bosiraphael added this pull request to the merge queue Jan 8, 2026
Merged via the queue into main with commit c207214 Jan 8, 2026
68 checks passed
@bosiraphael bosiraphael deleted the r--chart-sorting branch January 8, 2026 12:59
@twenty-eng-sync
Copy link
Copy Markdown

Hey @bosiraphael! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants