Cache book results from the NYT best sellers to the database #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Completed feature 62.
Currently, I've implemented it so that the server pulls weekly lists from NY Times back to 2013/01/01 and stores the all books found in the database with Title, Author, List Date, ISBN13 values (others can easily be added). This should make it possible to query the database for bestsellers from a month/year?
setInterval function is used to make requests approx. every 300 milliseconds which seems to avoid call limit issues.
Currently implemented as a route in route.js so that visiting /populateNY on the server will cause it to pull and populate the database. (The function wipes the book collection first (so duplicates aren't created) and I assume calls the NY api a lot so I recommend not doing this too much unless you don't mind not being able to pull books for a day or so).
I wasn't sure about putting the function here but wasn't sure where else to put it or how to have the server run it. If there's a better way I'm hoping it won't be much more difficult than copy pasting this code elsewhere.