learn-awesome / learn

A social network of lifelong learners built around humanity's universal learning map.
https://learnawesome.org/
Other
344 stars 41 forks source link

RFC: Cleanup fixtures and handle 429 error #215

Closed jish closed 4 years ago

jish commented 4 years ago

This is my proposal to handle #173 429 Too Many Requests when fetching Open Graph data from YouTube.

Closes: #173

When fetching Open Graph data from YouTube it can respond with a number of errors, including 429 Too Many Requests. Item.extract_opengraph_data already handles exceptions by logging the error and returning an empty hash. This patch applies the same logic to the YouTube fetching case.

https://github.com/learn-awesome/learn/blob/a8234ef43776911ca30d5463af80a1dfee9e86a8/app/models/item.rb#L571-L573

NOTE: I recommend reviewing each commit in this pull request separately.

The first commit in this branch https://github.com/learn-awesome/learn/commit/e3fb90a1e0f2aaadc3d7f3dddb9b86a2309cf68b cleans up some fixture data in order to get the test suite to run. It does not fix all of the tests, but it does allow rake test to run to completion. If this is not desirable, I would happy to extract that commit and create a separate pull request, or drop it entirely.

The third commit contains the tests and the fix https://github.com/learn-awesome/learn/commit/0169f2b1cee115fbf85251657c72631fc62c4a2b