Skip to content

fix: count only commits visible to the link viewer - #1416

Open
MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:fix/link-stats-match-visible-commits
Open

MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:fix/link-stats-match-visible-commits

Conversation

@MrPunyapal

@MrPunyapal MrPunyapal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Link statistics could count commits that are not visible in the feed, making the totals disagree with the content shown to the viewer.

Change

Applies the same visibility rules to the statistics query as the visible commit list, including approval and blocked-author filtering.

Tests

Focused link controller tests passed (7 tests, 98 assertions). Type checks and lint passed.

Summary by CodeRabbit

  • Bug Fixes
    • Link-page commit totals now match the commits visible to the current viewer, including their own pending commits and commits from organizations they belong to. Commits from blocked users and unrelated pending commits remain excluded. The displayed contributor count reflects the people who authored those visible commits.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Link statistics now use the current user’s commit visibility. The link controller passes that user to the stats query. The feature test covers visible commits, including organization commits, and confirms that blocked-user commits and unrelated pending commits remain excluded.

Changes: Link statistics

Layer / File(s) Summary
Calculate and verify visible commit statistics
app/Queries/LinkCommitsQuery.php, app/Http/Controllers/LinkController.php, tests/Feature/Controllers/LinkControllerTest.php
The stats query accepts a user and counts commits visible to that user. The controller passes the current user. The test expects four visible commits by three people and checks excluded commits.

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

Change: Bug fix

Suggested reviewers: mnapoli

Merge Risk: Minimal · up to a9778

Link statistics now match the commits visible to the requesting user, including the covered pending and organization cases.

Security architecture risk: Minimal · up to a9778

Statistics now use the same visibility rules as the displayed commits. The reviewed change does not introduce a new access path, broaden viewing permissions, or alter stored data.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed exposure is the aggregate commit and posting-user counts for one selected link. Newly included pending commits are governed by the same viewer-specific predicate already used for the feed; the change does not independently widen feed visibility.

Trust Boundaries and Controls

  • observed — The statistics identity comes from the controller’s CurrentUser parameter, not from the requested URL. The same identity is passed to the feed, keeping aggregate and content authorization aligned.

Resilience and Maintainability Implications

  • inferred — Sharing the visibility predicate reduces the risk of aggregate authorization drifting from feed authorization. The changed path performs reads and introduces no persistent multi-step transition requiring cleanup or recovery.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: the link statistics now count only commits visible to the link viewer. The raw summary confirms LinkCommitsQuery::stats now takes a User and counts commits visible to…
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: Title check

Explanation

The title states the main change: the link statistics now count only commits visible to the link viewer. The raw summary confirms LinkCommitsQuery::stats now takes a User and counts commits visible to that user, and LinkController passes the current user. The title is short, specific, and follows the conventional fix: prefix format.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 1 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
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: 987191a4-4093-495f-989a-61a2c8f89454
Commits

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

Files selected for processing: 3
  • app/Http/Controllers/LinkController.php
  • app/Queries/LinkCommitsQuery.php
  • tests/Feature/Controllers/LinkControllerTest.php

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

@MrPunyapal
MrPunyapal force-pushed the fix/link-stats-match-visible-commits branch from 98a4c90 to a97789c Compare November 3, 2026 05:55
@MrPunyapal
MrPunyapal marked this pull request as ready for review November 3, 2026 06:02
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