Skip to content

fix: sort By Item sponsor groups alphabetically - #1043

Open
caseylocker wants to merge 2 commits into
masterfrom
fix/byitem-sponsor-groups-alphabetical
Open

fix: sort By Item sponsor groups alphabetically#1043
caseylocker wants to merge 2 commits into
masterfrom
fix/byitem-sponsor-groups-alphabetical

Conversation

@caseylocker

Copy link
Copy Markdown

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

groupLinesBySponsorItem in src/components/sponsors/reports/ByItemView.js now sorts groups by sponsor name instead of by quantity, following the convention already established in build-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_date default 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:

  • the surviving test keeps the item ordering assertion and looks its group up by name
  • a new test, "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. eslint on both files: 0 errors.

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>
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 93c2b542-04c6-47f6-abbb-ba7624ba36bc


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 groupLinesBySponsorItem to 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.

Comment thread src/components/sponsors/reports/ByItemView.js
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>
@caseylocker caseylocker self-assigned this Aug 15, 2026
@caseylocker
caseylocker requested a review from smarcet August 15, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants