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

[YouTube] Drop support for removed dislikes #7410

Merged
merged 4 commits into from Dec 23, 2021
Merged

Conversation

pzygielo
Copy link
Contributor

@pzygielo pzygielo commented Dec 22, 2021

@shields-ci
Copy link

shields-ci commented Dec 22, 2021

Messages
📖 ✨ Thanks for your contribution to Shields, @pzygielo!

Generated by 🚫 dangerJS against 4d3349a

@pzygielo pzygielo changed the title Support no longer supporting dislikes on YouTube [YouTube] Support no longer supporting dislikes Dec 22, 2021
Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Feedback left inline below

viewCount: nonNegativeInteger,
likeCount: nonNegativeInteger,
commentCount: nonNegativeInteger,
favoriteCount: nonNegativeInteger,
Copy link
Member

Choose a reason for hiding this comment

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

As far as I know we don't actually need the favoriteCount value for any of our badges, so instead of adding what is essentially a duplicate schema for statistics, let's instead make the dislikeCount field optional by changing from nonNegativeInteger to optionalNonNegativeInteger (which can be imported from the same validators module)

Comment on lines 65 to 72
const likes = `${metric(statistics.likeCount)} 👍`
const dislikes =
statistics.dislikeCount !== undefined
? `${metric(statistics.dislikeCount)} 👎`
: ''
renderedBadge = {
...renderedBadge,
message: `${metric(statistics.likeCount)} 👍 ${metric(
statistics.dislikeCount
)} 👎`,
message: `${likes} ${dislikes}`,
Copy link
Member

Choose a reason for hiding this comment

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

We already have the withDislikes query parameter that allows the user to control whether or not the dislikes are included on their badge. If we hit this block then the user has explicitly asked for the dislike portion to be included as well, and as such we should instead display 0 👎.

Perhaps ${metric(statistics.dislikeCount || 0)} 👎 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But 0 👎 looks like there is no 👎, while in fact this is unknown. I was choosing between not presenting this piece or using ? 👎. I'm against using 0 for the case.

Copy link
Member

Choose a reason for hiding this comment

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

while in fact this is unknown.

What is your evidence for this? Do you have some documentation to the API or an example target that includes a "dislikeCount": 0 in the response?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, https://techcrunch.com/2021/11/10/youtube-is-removing-the-dislike-count-on-all-videos-across-its-platform/

Youtube has dropped the dislike count from public view altogether, and that's not something we'll ever be able to see. I think we should actually remove dislikes across the board

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather like this PR to only restore YT stats.
I think total dislikes removal could be the subject for the next one.

Copy link
Member

Choose a reason for hiding this comment

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

We have a feature that was based on an attribute in the API response that no longer exists, which in turn has broken badges. I don't understand what you're suggesting be split, could you elaborate?

We need a resolution to the actual issue, i.e. our badge needs to account for the upstream change. Splitting that into multiple PRs with ~5 line diffs is unnecessary overhead for us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Splitting that into multiple PRs with ~5 line diffs is unnecessary overhead for us

Understood.

Removed code IMO related to the dislikes.
Locally tested that the old links, with (now unused) parameter withDislikes render the no-parameterized version fine.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome thanks so much! Will give this a final pass here shortly

/^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👍 ([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👎$/
/^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) 👍$/
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for looking at the tests but as noted above we need to change the behavior a bit.

Additionally, we should instead add a new test for the scenario described in #7373. Given the specific use case of a missing dislikeCount field, it would probably be better for that to be a mocked test (https://github.com/badges/shields/blob/master/doc/service-tests.md#5-mocking-responses) given the likelihood for the upstream target to change/receive dislikes

@calebcartwright calebcartwright added the service-badge Accepted and actionable changes, features, and bugs label Dec 22, 2021
@pzygielo pzygielo marked this pull request as draft December 22, 2021 17:15
@pzygielo pzygielo marked this pull request as ready for review December 22, 2021 17:41
@pzygielo pzygielo marked this pull request as draft December 22, 2021 18:12
@pzygielo pzygielo marked this pull request as ready for review December 22, 2021 18:47
@pzygielo pzygielo changed the title [YouTube] Support no longer supporting dislikes [YouTube] Drop support for removed dislikes Dec 22, 2021
@shields-cd shields-cd temporarily deployed to shields-staging-pr-7410 December 22, 2021 19:06 Inactive
Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the updates and getting this one resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YouTube video view count: "invalid response data"
4 participants