Skip to content

Seth Mathai#66

Open
Sathyan08 wants to merge 13 commits intofscbco:mainfrom
Sathyan08:smathai
Open

Seth Mathai#66
Sathyan08 wants to merge 13 commits intofscbco:mainfrom
Sathyan08:smathai

Conversation

@Sathyan08
Copy link

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 sidekiq to run the job queue and whenever to create the Chron jobs.

You can find documentation for getting started with Sidekiq here. You can find the documentation for the whenever gem 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.

bundle exec sidekiq

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.

rake db:seed
whenever --update-crontab

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant