Closed nicknovitski closed 11 years ago
I'd appreciate a review of these changes, @nicknovitski. Now that we make multiple HTTP requests each time tutor.card
is called, and since the performance cost is negligible, we needn't paginate. Instead, we request the first page, which tells us how many pages there are in total, then request the remaining pages in parallel. There are now several functions involved in retrieving and transforming the data:
fetch
provides a callback with the specified page's contentextract
takes a page's content and returns a [code, name, id]
tripletmerge
takes an array of [code, name, id]
triplets and merges them into a single object
cf: http://gatherer.wizards.com/Pages/Card/Languages.aspx?multiverseid=289327
It's a bit annoying, since the vast majority of cards will only have one page, but to keep the responses consistent, they should all have a
page
property, with the collection held in alanguages
property or something like that.