Skip to content

fix(admin): count only finished plays on the dashboard leaderboards - #3388

Merged
Quick104 merged 1 commit into
mainfrom
fix/play-count-resume-sessions
Nov 2, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/play-count-resume-sessions

Conversation

@Quick104

@Quick104 Quick104 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

The admin dashboard's Top titles and Most active profiles widgets count every playback stop as a play. Someone who watches a film in ten short sittings shows ten plays for it, and a film they gave up on after a few minutes still ranks. The widgets are meant to show what people watch, so titles watched in many short sittings push out ones people actually finished. A user reported this on Discord. This change counts only finished plays.

Every playback stop past the 5% minimum-resume threshold writes a user_watch_history row, marked completed only past the watched threshold (90% by default). The leaderboard queries counted every playback row. Per-item play counts (the Plays sort, episode play counts, Jellyfin PlayCount) already count completed rows only.

Approach

Both leaderboard queries now count completed rows, through the filter that already left out marked-as-watched rows. A play on the dashboard now means the same thing as everywhere else in Silo: the profile reached the watched threshold. Watch time (total_seconds) still sums every sitting, so time spent on unfinished titles is still shown. docs/admin-api.md describes the new meaning of plays.

Merging consecutive sittings into one play would still credit unfinished watches, but it needs a gap setting to decide when one viewing ends. Counting finished plays is simpler and matches the rest of Silo.

This is a server-only change. The widget label "plays" still fits, so the web client is unchanged. The Apple and Android apps do not call this endpoint, Jellyfin has no equivalent leaderboard, and the user manual does not describe these widgets.

Validation

  • The Postgres leaderboard test now includes a title finished on its fourth sitting and one abandoned after two. It fails against main's query (4 and 2 plays) and passes with the fix.
  • Isolated sandbox with the same seeded data, before (main) and after (this branch): see Evidence.
  • Go build, gofmt, vet, lint-changed, lint-router-recovery, route inventory, API v2 OpenAPI and contract, local paths, size ratchet, bidi, and v1 route freeze checks pass.
  • make test-go failed in internal/cache and internal/historyimport while a sandbox image build was loading the same host. Neither package is touched here, and both pass when rerun on this branch and on main.
  • Web gate not run: no web files changed.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3388/

Surface and build: web admin dashboard at desktop and phone width. Before is main at 81ae2ce, after is this branch, same sandbox and data. Ten 5-minute sittings of a 50-minute title go from 10 plays to 1 play. Watch time is unchanged.

Risks

A title nobody finished in the window no longer appears in Top titles, and a profile that starts many titles but rarely finishes one ranks lower in Most active profiles. The plays field keeps its name and type, and its meaning narrows to finished plays. No migration.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verification pending
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Fix admin leaderboards to count only completed plays

Fixes the admin top-activity leaderboards so that a "play" counts only history rows marked completed, from either playback or legacy sources. Previously the adminTopActivityPlayFilter predicate allowed any row from those sources, so unfinished sittings inflated the title and profile play counts. Time from finalized sessions still counts toward total_seconds, and mark rows remain excluded.

  • Updates the integration test to TestAdminTopActivityCountsFinishedPlayback with fixtures covering resumed and abandoned sittings, and re-registers it in the DB contract list db-contracts.txt
  • Updates the plays definition in the admin API docs admin-api.md
  • Risk: leaderboard play counts drop for users with many incomplete sittings; check adminTopActivityPlayFilter in admin_stats_top.go to review the completed-row condition

Macroscope summarized 5504cf9.

Every playback stop writes a watch-history row, and the Top titles and Most
active profiles widgets counted each one as a play. A title watched in ten
sittings showed ten plays, and a title abandoned partway still ranked.

Count completed playback rows only, as the per-item play counts already do.
Watch time is unchanged and still includes every sitting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 2, 2026
@silo-kody

silo-kody Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f6424c7c-7de2-4d74-b222-d40f526cd196
Commits

Reviewing files that changed from the base of the PR and between 81ae2ce and 5504cf9.

Files selected for processing: 4
  • docs/admin-api.md
  • internal/api/handlers/admin_stats_top.go
  • internal/api/handlers/admin_stats_top_test.go
  • scripts/ci/db-contracts.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T00:07:58.455173Z 5504cf9 PR opened
🔒 Security Review ✅ Completed 2026-11-02T00:08:42.655174Z 5504cf9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@macroscopeapp

macroscopeapp Bot commented Nov 2, 2026

Copy link
Copy Markdown

The Evidence section contains only Evidence: EVIDENCE_LINK, not captures or a published evidence URL, so it does not show the visible change.

  • Top titles can show a different ranking or omit titles when unfinished plays no longer count (internal/api/handlers/admin_stats_top.go). Add before-and-after admin-dashboard captures of the same data and time window at desktop and phone widths, and identify the surface and build or commit for each.
  • Most active profiles can show a different ranking or omit profiles for the same reason (internal/api/handlers/admin_stats_top.go). The same before-and-after captures can cover this widget too.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Nov 2, 2026
@Quick104
Quick104 merged commit 7e0765b into main Nov 2, 2026
20 of 21 checks passed
@Quick104
Quick104 deleted the fix/play-count-resume-sessions branch November 2, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant