fix(node): dedupe mirror and canonical repo rows on list surfaces (#6)#73
fix(node): dedupe mirror and canonical repo rows on list surfaces (#6)#73beardthelion wants to merge 1 commit into
Conversation
The non-paged GET /api/v1/repos legacy path and list_federated_repos returned both the short-owner peer mirror row and the canonical did:key row for the same logical repo, so profiles rendered the repo twice. Only the paged path collapsed them, in SQL. Add a dedupe_canonical_repos helper that groups by (normalized owner, name), keeps the canonical non-mirror row (tie broken by earliest created_at), and carries the group's latest updated_at onto the survivor, matching the paged SQL dedup. Apply it at both non-paged surfaces and cover it with unit tests.
|
Warning Review limit reached
More reviews will be available in 53 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary
Profile and repo-list surfaces rendered the same logical repo twice when a short-owner peer mirror row and the canonical
did:key:row both existed. This collapses them to one card on the surfaces that were missing the dedup.Motivation & context
Closes #6
node.gitlawb.comshowed twonipmodcards on a profile: one from the peer mirror row (owner_did = "z6Mk…", description "mirrored from peer") and one from the canonical row (owner_did = "did:key:z6Mk…"). The paged repo list already deduped these in SQL, but the non-pagedGET /api/v1/reposlegacy path andlist_federated_reposreturned every matching row, so both showed up.Kind of change
What changed
Crate touched:
gitlawb-node.dedupe_canonical_reposinapi/repos.rs: groups rows by(normalized owner, name)(the key segment after the last:, sodid:key:z6Mk…and the barez6Mk…mirror row collapse together), keeps the canonical row (non-mirror beats "mirrored from peer", ties broken by earliestcreated_at), and carries the group's most recentupdated_atonto the survivor so a gossip push that only touched the mirror row still floats the repo to the top. This matches the existing SQL dedup inDb::list_all_repos_paged.list_reposfallback andlist_federated_repos. As a side effect the legacy path'sX-Total-Countnow counts logical repos rather than raw rows, consistent with the paged path.repos::testsmodule covering canonical-wins, distinct-repos-preserved, same-owner-different-repo, and the mirror tie-break.How a reviewer can verify
Before you request review
cargo test --workspacepasses locallycargo fmt --allandcargo clippy --workspace --all-targets -- -D warningsare cleanfeat(...),fix(...),docs(...)).env.exampleupdated if behavior or config changed (or N/A)Notes for reviewers
The dedup logic now lives in two places: the SQL
DISTINCT ONinDb::list_all_repos_pagedand this Rust helper for the non-paged surfaces. They use the same preference rules and the helper's doc comment flags that they must stay in sync. Consolidating both behind one path is possible later but would change the legacy "return all rows" contract that peer/CLI callers rely on, so I kept it out of scope.