Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This fork uses a Chron job to periodically retrieve the ids of the top stories, identify stories not recorded in our database, and then both fetch and store the data in our local database. I decided to use
sidekiqto run the job queue andwheneverto create the Chron jobs.You can find documentation for getting started with Sidekiq here. You can find the documentation for the
whenevergem here.Getting Started
To get started, you will need to install Redis if you have not done so already. You can start the Sidekiq queue by running the following command.
After that, you can re-run the seeds to create the Hacker News Story records in the database and create the chron jobs to periodically update them.
Notes
I chose to call the "Stars" described in the prompt as "Recommendations" as the prompt indicated that the stars are synonymous with upvotes. I believed that the term "Recommendation" was more direct and easy to implement.
I only did minimal styling and testing as this is intended to be a simple internal app. If we were to continue development on this app, we would probably need to flesh out the testing more. I did add the basic test infrastructure mostly to demonstrate that I could write Rspec tests. I am not sure a small, simple, non-business critical app would actually require more extensive testing.
I decided to use Chron and Sidekiq as we want to store data locally whenever possible as we cannot rely on third party apis, and we want to reduce latency by making the api requests to Hacker News asynchronously. I used Sidekiq so that the app can process these jobs using multiple threads, which greatly reduces the time needed to process the jobs.