fix: sort By Item sponsor groups alphabetically - #1043
Conversation
The sponsor accordions in the Purchase Details "By Item" report were ordered by total units descending, with the name only as a tiebreak, which reads as no order at all. Nothing sorts that level explicitly (the column headers reorder items within a group), so it now defaults to alphabetical, following the convention already used by the pivot tree: unknown bucket last, then name ascending, case insensitive. This also decides which sponsors land on which client side page. Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adjusts the default ordering of sponsor accordion groups in the Purchase Details By Item report (“By Sponsor” layout) so that sponsor groups are sorted alphabetically (case-insensitive) with the unknown bucket last, aligning with the existing pivot-tree sorting convention.
Changes:
- Update
groupLinesBySponsorItemto sort sponsor groups by sponsor name (case-insensitive), keeping the unknown bucket last. - Update the ByItemView group-sorting test to focus on item ordering within a group, and add a new test asserting sponsor group alphabetical order (including unknown-last behavior).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/components/sponsors/reports/ByItemView.js | Changes sponsor-group sorting comparator to default to alphabetical ordering (unknown last). |
| src/components/sponsors/reports/tests/ByItemView.test.js | Refactors existing test to avoid asserting old group-order contract; adds coverage for alphabetical sponsor-group sorting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The previous comment claimed the comparator followed the pivot tree convention, but the pivot tree keys unknown on the sponsor id (pivot-defs.js AXES.sponsor.isUnknown) while this one keys on the name. That divergence is deliberate, so say why instead of misdescribing it. Comment only, no behavior change. Co-Authored-By: Claude <noreply@anthropic.com>
ref: https://app.clickup.com/t/9014802374/86bbej1g1
Problem
In the Purchase Details By Item report, "By Sponsor" layout, the sponsor accordions came out in what reads as no order at all. They were sorted by total units descending, with the sponsor name only as a tiebreak, so the visible ordering looked arbitrary (the reported screenshot happened to show 8 units / 6 units / 6 units, where the alphabetical looking part was just the tiebreak).
Nothing sorts that level explicitly: the column headers (
ITEM_HEADERS/sortItems) reorder items within a sponsor group, and there is no control for the group list itself. So per the request, with no explicit sort the default should be alphabetical.Change
groupLinesBySponsorIteminsrc/components/sponsors/reports/ByItemView.jsnow sorts groups by sponsor name instead of by quantity, following the convention already established inbuild-pivot-tree.js: the unknown bucket sorts last, then name ascending, case insensitive.This also decides which sponsors land on which page, since the view pages over the group list client side.
Untouched on purpose:
finalizeItems(item order inside a group),groupLinesByItem(the All Sponsors layout), and the flat Orders view, whose-order_datedefault is an explicit, intentional sort.Tests
The old test
"sorts items qty desc then orders desc, sponsors by totalQty desc"asserted["Big", "Small"], which is alphabetical too, so it would have kept passing while asserting a contract that no longer exists. It is split:"sorts sponsor groups alphabetically, not by qty, with unknown last", uses acme / Nokia / zeta / unknown with Nokia at qty 99, so the old comparator would have put Nokia first. It covers case insensitivity and the null sponsor bucket.Full suite: 166 suites, 1502 tests passing.
eslinton both files: 0 errors.