Making WordPress.org

Opened 7 years ago

Last modified 18 months ago

#3037 new enhancement

WordPress.tv: Show the views of the video

Reported by: mte90's profile Mte90 Owned by:
Milestone: Priority: normal
Component: WordPress.tv Keywords: needs-patch
Cc:

Description

Actually on video pages is not possible to show the views of the video, this is very uncomfortable because is the only reason why I share the youtube links.
I am not sure if that value is saved in the system but in any case is one of the basic features of a video service and I think that is important to have that also on WordPress.tv

Attachments (1)

Capture.PNG (38.4 KB) - added by casiepa 7 years ago.
Backed stats

Download all attachments as: .zip

Change History (13)

#1 @casiepa
7 years ago

As an admin, the stats can be found on e.g. https://wptv.wordpress.com/wp-admin/index.php?page=stats&view=post&post=72476 , so the views are somewhere tracked.

I should be sufficient to display the total number somewhere on the page https://wordpress.tv/2017/08/01/daniele-scasciafratte-why-your-community-needs-a-glossary/

@casiepa
7 years ago

Backed stats

#2 @SergeyBiryukov
7 years ago

  • Summary changed from Show the views of the video to WordPress.tv: Show the views of the video

This ticket was mentioned in Slack in #wptv by casiepa. View the logs.


7 years ago

#4 @JerrySarcastic
7 years ago

Because WPTV is on wpcom (VIP) it may be possible to leverage the wpcom REST API to get that stat: https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/video/%24post_id/

This ticket was mentioned in Slack in #wptv by casiepa. View the logs.


5 years ago

#6 @davidperez
5 years ago

I think is a good idea to show the views. You can see which Videos are popular, and even for the Speakers and Organizers, can see which videos has more views and try to learn which ones has more interest.

+1 to implement it!

#7 @BrashRebel
5 years ago

  • Keywords needs-patch added

Jerry's right, this looks completely possible and would be an exciting enhancement. Thanks for the suggestion @Mte90!

This ticket was mentioned in Slack in #wptv by mboynes. View the logs.


18 months ago

#9 @mboynes
18 months ago

This sounds like a fantastic idea, and I'm interested in moving it forward. Has any work been done on it yet? If not, what is the process for contributing a feature as robust as this? Some decisions will need to be made (both architectural and operational). I'm content making all the calls myself if there is no process, or if that is the process :-).

As I see it, this could be its own "plugin" in the wptv theme to keep its functionality orthogonal. The plugin will need to:

  1. Have a library for querying for video stats from the wpcom rest api.
    • I'm assuming that the site runs Jetpack (viewing source basically confirms that, since Jetpack's global styles are included). I'm hoping, but need to confirm, that we'll be able to use Jetpack to make an authenticated request to the video stats endpoint as not all authenticated endpoints are available to Jetpack. We'll want to confirm this early in the process, as it could introduce a significant wrinkle. If Jetpack can't do this out of the box, we're not out of options, but it would be harder.
  2. Provide an API endpoint to the frontend for getting stats for a given video asynchronously. We won't want to query the wpcom api during pageload or else we'll adversely impact page speed as well as make the entire site significantly more fragile.
    • Caching will be important, as well as finding the right balance of cache duration (I lean toward a stepped approach here based on the age of the video, ranging from 5 minutes for new videos to 24 hours for older videos).
    • We'll have to make a decision about the scope and visibility of this endpoint. Should it be another public, documented API endpoint? Public but undocumented? Private-ish (nonce-secured), for ddos-protection? Left to my own devices, I would make it public but undocumented at the start to err on the side of public but maintain the option of locking it down if it becomes a problem.
  3. Provide a UX component that gets the stats for a video and renders it.

Is there documentation anywhere on building a local development environment for wordpress.tv? I can certainly wing it using the source in svn. I get the gist of how the code is organized, but it would be nice to know I'm not missing a step.

#10 @mboynes
18 months ago

I was able to confirm that Jetpack can request that API endpoint using:

Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_blog();

Now having used the API endpoint, it looks like it might not be possible to get a simple cumulative view count for a video. Perhaps someone from WordPress.com could chime in to offer some insight, but as far as I can tell from the docs, the response only returns views over a requested period of time: day, week, month, or year. If we say period=all it gives the last 60 days, I guess. When we query period=year, we get the last 12-13 months, and we can add them up to get total views over the last year, but that looks to be as far back as we can go.

Can anyone offer an undocumented solution to getting the total view count for a video?

#11 @dd32
18 months ago

As this is a theme that runs on WordPress.com, there's likely an internal function that can be called to fetch that data.

I'm not familiar with the dotcom stats systems to know if such a function exists (and what it'd be called, but for patch purposes, I'd stub in a function wptv_get_view_count() { return rand(1, 100000); }).

I'm not confident that adding public view stats is something that is wanted from a project perspective however, so I can't exactly say if this is something we'd move forward with.
That's especially true if video view counts are similar to the screenshot above, where it's counted in the hundreds.. it doesn't seem like it offers any benefit to anyone..

#12 @mboynes
18 months ago

@JerrySarcastic it looks like you work at A8c, do you have any insight on getting total view counts for videos?

Note: See TracTickets for help on using tickets.