Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 799 forks source link

VideoPress: add logic to migrate metadata fields used on filtering #26822

Open lhkowalski opened 2 years ago

lhkowalski commented 2 years ago

We recently added new filters for the videos based on some metadata fields #26777. We also started to save this new metadata fields when a change is made on a given video #26769.

Now we need to migrate/create this new fields for all the VideoPress existing videos on a given site, so the filtering for existing videos work as expected.

Some ideas:

lhkowalski commented 1 year ago

Just to mirror some conversations made over Slack:

I took some time to investigate how to use background tasks for this, as well as thinking about some alternatives for it, but in the end I made an interesting discovery:

This specific change made on this PR has the side effect of migrating this fields for us whenever someone loads the video on the VideoPress library as well as on players inside posts or pages.

I knew that it would happen for the video featch on the VideoPress library, but was not aware it would work on the player as well.

This happens because the mentioned change migrates the fields when a request for the video info is made, from whatever source: the VideoPress library, the "Edit video details" page or the player. The visitor doesn't even need to play the video, it works even when the video is private and the visitor does not have the rights to watch it (because the player does a first load on the video info).

In the end, it means that the migration will finish automatically some time, as soon as every video has been watched on the site or listed/managed on the library.

For context: the migration is for 2 fields used for filtering inside the VideoPress library, privacy_setting and rating. The migration consists in copying the value of these 2 fields to a higher level post meta variable, so it becomes possible to filter the videos using the fields. When the fields are not migrated for a given video, the video will not show up on a filtered list (but will show if searched).

So we are going to reduce the priority for a deliberate migration feature, and favor other tasks for now. This is why the priority got reduced to low.