fix(inbox): tiebreak priority sort by newest first#2787
Open
rafaeelaudibert wants to merge 3 commits into
Open
fix(inbox): tiebreak priority sort by newest first#2787rafaeelaudibert wants to merge 3 commits into
rafaeelaudibert wants to merge 3 commits into
Conversation
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
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,priority→status,priority,-created_at.Why this works
The backend (
SignalReportViewSet) parses theorderingquery param by splitting on commas and applying each clause in order, withcreated_atalready in its ordering whitelist andidappended 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_weightandcreated_atsorts are unchanged.Testing
buildSignalReportListOrdering("priority", "asc") === "status,priority,-created_at".reportFiltering.test.tspasses (22 tests).🤖 Generated with Claude Code