Skip to content

Stats: video details follow-ups — drop the media request, fix hours-watched formatting - #112528

Merged
dognose24 merged 3 commits into
trunkfrom
fix/stats-videopress-module-watch-time-format
Jul 10, 2026
Merged

Stats: video details follow-ups — drop the media request, fix hours-watched formatting#112528
dognose24 merged 3 commits into
trunkfrom
fix/stats-videopress-module-watch-time-format

Conversation

@dognose24

@dognose24 dognose24 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #112499.

Proposed Changes

  • Stop fetching the media item on the video details page. This commit was pushed to Stats: modernize the VideoPress video details page #112499 moments after the squash-merge snapshot was taken, so it never landed on trunk: the media request only remained as a title/date fallback after the retention card was removed, but the stats/video response's attachment post is the primary source for both in every environment — while the media request is a guaranteed 404 in Odyssey Stats (the stats-app proxy has no media route) and redundant on Calypso.
  • Fix the Hours Watched formatting on the All videos page grid (videopress-stats-module), per this #112499 review thread: watch_time > 1 rendered both 0 and exactly 1 as < 1.0 — zero hours reading as "less than one" is misleading. Values of exactly 0 and >= 1 now render as numbers; < 1.0 remains only for values strictly between zero and one, matching the video details metric cards.

Why are these changes being made?

Testing Instructions

  • Open a video details page (/stats/day/videodetails/:site?post=<id>) with the network tab open — there should be no /media/<id> request (previously a v1.2 media request fired, and 404ed in Odyssey Stats); the header card title and published date still render.
  • Open Stats → Videos (/stats/day/videoplays/:site): a video with zero watch time should show 0.0 (previously < 1.0), exactly 1 hour shows 1.0, a fraction of an hour still shows < 1.0, larger values unchanged.
Before After
截圖 2026-07-11 凌晨2 08 17 截圖 2026-07-11 凌晨2 08 23

API response

截圖 2026-07-11 凌晨2 09 57

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • For UI changes, have you tested the affected components in dark mode?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

🤖 Generated with Claude Code

'watch_time > 1' rendered both 0 and exactly 1 as '< 1.0' — zero hours
reading as 'less than one' is misleading. Matches the fix already
applied to the video details metric cards in #112499.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
It only remained as a title/date fallback after the retention card was
removed, but the statsVideo response's attachment post is the primary
source for both and is available in every environment — while the media
request is a guaranteed 404 in Odyssey and redundant in Calypso.

Part of STATS-299.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dognose24 dognose24 changed the title Stats: show exact zero and one hours watched on the All videos page Stats: video details follow-ups — drop the media request, fix hours-watched formatting Jul 10, 2026
@dognose24
dognose24 marked this pull request as ready for review July 10, 2026 18:29
@dognose24
dognose24 requested a review from Copilot July 10, 2026 18:31
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 10, 2026
@dognose24
dognose24 requested a review from a team July 10, 2026 18:31
@dognose24 dognose24 self-assigned this Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up to #112499 that removes a redundant (and Odyssey-incompatible) media-item fetch from the Stats video details page, and corrects “Hours Watched” formatting in the VideoPress stats grid so 0 and 1 hours display as numeric values rather than < 1.0.

Changes:

  • Remove QueryMedia / getMediaItem usage from stats-video-detail and rely solely on the statsVideo attachment post for title/date.
  • Adjust “Hours Watched” display logic in videopress-stats-module to render 0.0 and >= 1.0 as numbers, reserving < 1.0 for values strictly between 0 and 1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
client/my-sites/stats/videopress-stats-module/index.jsx Updates the hours-watched cell formatting logic for the All videos grid.
client/my-sites/stats/stats-video-detail/index.tsx Removes the media-item request/fallback and uses statsVideo post fields for the header card.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/my-sites/stats/stats-video-detail/index.tsx Outdated
A failed statsVideo request left data null forever, so the header card
shimmered indefinitely — and the chart and embeds card had the same
gap. Derive loading from hasSiteStatsQueryFailed as well, so a failure
resolves to the hidden card / empty states instead.

Part of STATS-299 follow-ups.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@dognose24
dognose24 added this pull request to the merge queue Jul 10, 2026
Merged via the queue into trunk with commit 36ad3ef Jul 10, 2026
16 checks passed
@dognose24
dognose24 deleted the fix/stats-videopress-module-watch-time-format branch July 10, 2026 19:01
@github-actions github-actions Bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 10, 2026
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.

3 participants