Skip to content

fix: use stable ordering when top links have equal scores - #1419

Open
MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:fix/stabilize-top-links-tie-order
Open

MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:fix/stabilize-top-links-tie-order

Conversation

@MrPunyapal

@MrPunyapal MrPunyapal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Links with equal scores can change order between requests because the query does not define a tie-breaker.

Change

Adds deterministic tie ordering so the same links remain in the same order for a given result set.

Tests

Focused link controller tests passed (8 tests, 104 assertions). Type checks and lint passed.

Summary by CodeRabbit

  • Bug Fixes
    • Link listings now use link ID to consistently order entries when their existing ranking and mention dates are tied.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a79ef1b-4b5b-428d-8564-4c28c5687bfa
Commits

Reviewing files that changed from the base of the PR and between 9ebfbb9 and fdadb06.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The top links query now sorts by link_previews.id ascending after its existing ranking criteria. A feature test checks the displayed URL order when three links have commits with the same timestamp.

Changes: Top links ordering

Layer / File(s) Summary
Query tie-breaker and feature test
app/Queries/TopLinksQuery.php, tests/Feature/Controllers/LinkControllerTest.php
The query adds ascending link_previews.id as a final sort criterion. The test checks that links with equally timed commits appear in ascending ID order.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: mnapoli

Merge Risk: Minimal · previous review f5c10

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding stable ordering for top links with equal scores.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7e2b48b-2d5a-408a-8a3c-310fd9b18ec8
Commits

Reviewing files that changed from the base of the PR and between c934501 and f5c10f6.

Files selected for processing: 2
  • app/Queries/TopLinksQuery.php
  • tests/Feature/Controllers/LinkControllerTest.php

Limit details: You’ve used all 10 included reviews currently available.

@MrPunyapal
MrPunyapal force-pushed the fix/stabilize-top-links-tie-order branch from 956eae1 to f5c10f6 Compare November 3, 2026 05:55
@MrPunyapal
MrPunyapal marked this pull request as ready for review November 3, 2026 06:02
@MrPunyapal
MrPunyapal force-pushed the fix/stabilize-top-links-tie-order branch from f5c10f6 to 9ebfbb9 Compare November 3, 2026 21:04
@MrPunyapal
MrPunyapal force-pushed the fix/stabilize-top-links-tie-order branch from 9ebfbb9 to fdadb06 Compare November 4, 2026 11:07
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