Skip to content

fix(inbox): tiebreak priority sort by newest first#2787

Open
rafaeelaudibert wants to merge 3 commits into
mainfrom
posthog-code/inbox-priority-sort-tiebreak
Open

fix(inbox): tiebreak priority sort by newest first#2787
rafaeelaudibert wants to merge 3 commits into
mainfrom
posthog-code/inbox-priority-sort-tiebreak

Conversation

@rafaeelaudibert

Copy link
Copy Markdown
Member

Summary

When sorting the inbox by priority, reports are now secondarily sorted by timestamp DESC (newest first) within each priority tier.

Priority is a coarse 5-bucket rank (P0–P4), so without a tiebreak, reports in the same tier came back in an arbitrary order. The ordering string sent to the signal report list API changes from status,prioritystatus,priority,-created_at.

Why this works

The backend (SignalReportViewSet) parses the ordering query param by splitting on commas and applying each clause in order, with created_at already in its ordering whitelist and id appended as a final tiebreak. So this is a frontend-only change — no API changes needed.

The tiebreak is scoped to the priority sort; the total_weight and created_at sorts are unchanged.

Testing

  • Added a unit test asserting buildSignalReportListOrdering("priority", "asc") === "status,priority,-created_at".
  • reportFiltering.test.ts passes (22 tests).

🤖 Generated with Claude Code

Priority is a coarse 5-bucket rank (P0–P4), so when sorting the inbox by
priority, reports in the same tier came back in an arbitrary order. Append a
`-created_at` clause so the newest report wins within a tier.

The signal report list API already applies comma-separated ordering clauses in
order (and falls back to `id`), so this is a frontend-only change scoped to the
priority sort; total_weight and created_at sorts are unchanged.

Generated-By: PostHog Code
Task-Id: 3a0c3340-da9d-4189-82ac-8c9e310051c3
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit bf8860c.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/core/src/inbox/reportFiltering.test.ts, line 101-113 (link)

    P2 The new standalone it for the priority tiebreak breaks the team's preference for parameterised tests. It can be folded into the existing it.each table — and the "priority", "desc" direction (which produces "status,-priority,-created_at") is left untested entirely.

    Context Used: Do not attempt to comment on incorrect alphabetica... (source)

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/core/src/inbox/reportFiltering.test.ts
    Line: 101-113
    
    Comment:
    The new standalone `it` for the priority tiebreak breaks the team's preference for parameterised tests. It can be folded into the existing `it.each` table — and the `"priority", "desc"` direction (which produces `"status,-priority,-created_at"`) is left untested entirely.
    
    
    
    **Context Used:** Do not attempt to comment on incorrect alphabetica... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/core/src/inbox/reportFiltering.test.ts:101-113
The new standalone `it` for the priority tiebreak breaks the team's preference for parameterised tests. It can be folded into the existing `it.each` table — and the `"priority", "desc"` direction (which produces `"status,-priority,-created_at"`) is left untested entirely.

```suggestion
  it.each([
    ["total_weight", "desc", "status,-total_weight"],
    ["created_at", "asc", "status,created_at"],
    ["signal_count", "desc", "status,-signal_count"],
    ["priority", "asc", "status,priority,-created_at"],
    ["priority", "desc", "status,-priority,-created_at"],
  ] as const)("orders by status then %s (%s)", (field, direction, expected) => {
    expect(buildSignalReportListOrdering(field, direction)).toBe(expected);
  });
```

Reviews (1): Last reviewed commit: "fix(inbox): tiebreak priority sort by ne..." | Re-trigger Greptile

@rafaeelaudibert rafaeelaudibert requested a review from a team June 19, 2026 20:22
Assemble the ordering clauses with a join instead of a literal comma fragment,
and give every non-priority sort a `priority` tiebreak so the most urgent report
wins when the primary field can't separate two reports. The priority sort still
tiebreaks by `-created_at` (newest first within a tier).

Generated-By: PostHog Code
Task-Id: 3a0c3340-da9d-4189-82ac-8c9e310051c3
Fold the priority tiebreak test into an it.each table to match the team's
parameterised-test preference, and add the previously-untested priority/desc
direction (status,-priority,-created_at).

Generated-By: PostHog Code
Task-Id: 3a0c3340-da9d-4189-82ac-8c9e310051c3
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.

1 participant