Background Tasks & Rails – A Sidekiq Example

This post involves a little bit of everything–queuing (Sidekiq), JSON, API calls, redis, database manipulation. Enjoy!

The latest feature I am pushing to Dotawithme is listing the players by who is currently online. This is an oft requested feature (with good reason – DOTA players are impatient) but I wasn’t entirely sure what the best way to go about this was.

Of course I couldn’t just hammer Valve’s Steam API or I would quickly hit my daily limit. This means I need to create a background process to run at set intervals and update the database accordingly. There are many different gems to help your Rails app out with this and I settled on Sidekiq (‘Sidekick’) because it’s fast and (supposedly) simple to use.

Continue reading

Writing My First Gem for Rails

If you aren’t familiar with gems they are the Ruby on Rails equivalent to WordPress plugins. I wanted to learn how to write my own so I found this great tutorial at Quick Left.

I had an idea for a gem that I wanted to make quickly so I didn’t build the exact same gem as the tutorial. Instead I just wanted to make a simple gem so I could lookup info about a visitor on a website.

Continue reading