Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prismic linting step for audio/video duration format (xx:xx) #11188

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

davidpmccormick
Copy link
Contributor

@davidpmccormick davidpmccormick commented Sep 18, 2024

What does this change?

We've changed the Guide Stop audio/video duration fields to be strings rather than numbers, and we're requesting that editors enter them in the format xx:xx but we can't validate this at the point of data entry (because Prismic) so this adds a rule to the lintPrimsic script to check the duration strings against a regex that expects {number}{number}:{number}{number}.

How to test

I deliberately entered the last of the video durations for Jason as 4:37 (instead of 04:37) to verify that we're catching the errors. I'm planning on updating this, but can wait if you'd also like to test it yourselves.

How can we measure success?

Site has consistent guide-stop durations

Have we considered potential risks?

A guide stop with a/v durations longer than an hour would cause issues. Might be worth making the regex a bit more tolerant? <– did this

@davidpmccormick davidpmccormick requested a review from a team September 18, 2024 10:15
function detectIncorrectAudioVideoDuration(doc: any): string[] {
const guideStopSlices =
doc?.data?.slices?.filter(s => s.slice_type === 'guide_stop') || [];
const regex = /^(\d{2,}:)?[0-5][0-9]:[0-5][0-9]$/; // e.g. 03:30 (optionally 01:03:30)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice one 👍 thanks for explaining it too

@rcantin-w
Copy link
Contributor

Happy for it to go in with the Jason "error" still there so you can test, if you want to run the linter manually and see it pop up 🤷‍♀️ with or without!

@rcantin-w rcantin-w merged commit 360c5c5 into main Sep 18, 2024
7 checks passed
@rcantin-w rcantin-w deleted the lint-av-duration-format branch September 18, 2024 16:21
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