Skip to content

fix(dashboard): augment Silently-costing card with transcode breakdowns#142

Merged
ShogyX merged 1 commit into
mainfrom
fix/dashboard-silently-costing
May 27, 2026
Merged

fix(dashboard): augment Silently-costing card with transcode breakdowns#142
ShogyX merged 1 commit into
mainfrom
fix/dashboard-silently-costing

Conversation

@ShogyX
Copy link
Copy Markdown
Owner

@ShogyX ShogyX commented May 27, 2026

Summary

Second of three planned PRs for the Dashboard overhaul. This one replaces the single "top transcoded files" list inside the Silently costing you card with a four-axis breakdown that tells the operator what is actually costing them:

  • Top video + audio codecs forcing transcodes — video from PlaybackEvent.source_codec; audio joined from MediaFile.audio_codec (the event row doesn't carry an audio codec column).
  • Top devices triggering transcodes + each device's most-common transcode reasons ("what this device doesn't like").
  • Top transcode reasons overall.
  • Average source bitrate split direct-played vs transcoded — per-stream weight, not aggregate traffic. The interesting number is "transcoded streams cost more per stream because they're re-encoding a fat remux down".

Backend

  • New app/services/dashboard/transcode_insights.py computes all four breakdowns + totals + bitrate split in a single service call.
  • New GET /api/v1/dashboard/transcode-insights?days=30 endpoint (1..365 day window).
  • New TranscodeInsightsRead schema with four nested Read models.

Frontend

  • New useDashboardTranscodeInsights hook keyed off the dashboard's existing range; "All time" maps to 365 to keep the COUNT(*) bounded.
  • New TranscodeInsightsBlock sub-component inside the existing "Silently costing you" card, between the hero copy and the trend chart. Hidden when the window has no transcodes (the hero copy already explains a quiet library).

Test plan

  • pytest backend/tests/integration/test_dashboard_transcode_insights_v111.py — 6 tests pass (empty window, codec counting filters to transcodes only, audio codec joins MediaFile, per-device top reasons, bitrate split, ?days= window bound).
  • npx tsc --noEmit clean.
  • vitest run src/features/dashboard — 40/40 pass.
  • Manual on the live install: verify the four breakdowns render with the actual data + that the 7d / 30d / 90d selector at the top of the dashboard drives the same window.

Next up

  • PR merge #3Reclaimable interactive picker: target codec / container / bitrate + filters on source codec / size / container / bitrate.

🤖 Generated with Claude Code

from __future__ import annotations

import datetime as _dt
from collections.abc import Iterable
Replaces the single "top transcoded files" list with a richer
four-axis breakdown of WHAT is costing the operator:

  * Top video + audio codecs forcing transcodes (video from
    PlaybackEvent.source_codec; audio from MediaFile.audio_codec
    via a join, since the event row doesn't carry it).
  * Top devices triggering transcodes + each device's top
    transcode reasons ("what this device doesn't like").
  * Top transcode reasons overall.
  * Average source bitrate split direct-play vs transcoded
    (operators want the per-stream weight, not aggregate
    traffic — transcoded streams that re-encode to a lower
    bitrate dominate when the source is a fat remux).

Backend:

  * New ``app/services/dashboard/transcode_insights.py`` service.
    All four breakdowns + the totals + the bitrate split are
    computed in a single service call so the card renders without
    N round-trips. Bounded by ``?days=`` (1..365).
  * New ``GET /api/v1/dashboard/transcode-insights`` endpoint.
  * New ``TranscodeInsightsRead`` schema (plus the four nested
    Read models).

Frontend:

  * New ``useDashboardTranscodeInsights`` hook keyed off the
    dashboard's existing range. ``All time`` is treated as 365
    days so the backend COUNT(*) stays bounded.
  * New ``TranscodeInsightsBlock`` sub-component rendered inside
    the existing "Silently costing you" card, between the hero
    copy + the trend chart. Hidden when the window has no
    transcodes — the hero copy already explains a quiet library.

Tests:

  * ``tests/integration/test_dashboard_transcode_insights_v111.py``
    — 6 tests pin the contract (empty-window zero, codec
    counting filters to transcodes only, audio codec joins
    MediaFile, device top-reasons surface per-device failure
    modes, bitrate split, ``?days=`` window bound).
  * Frontend: ``tsc --noEmit`` clean; ``vitest run
    src/features/dashboard`` — 40/40 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ShogyX ShogyX force-pushed the fix/dashboard-silently-costing branch from 4357fe3 to ccc18af Compare May 27, 2026 18:32
@ShogyX ShogyX merged commit d3469b4 into main May 27, 2026
7 checks passed
@ShogyX ShogyX deleted the fix/dashboard-silently-costing branch May 27, 2026 19:51
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.

2 participants