simeonwillbanks/mygists — pull request #41 by simeonwillbanks (2013-01-29 21:33:55+00:00)
Title: Push fetching a gist's star status into the background

This greatly decreases the number of GitHub API HTTP requests on each MyGists profile request.

`MyGists::Fetch#gists` use to loop over each fetched gist and make a subsequent GitHub API HTTP request for each one. If a new user joined MyGists and they had 100 gists, their first profile request would require 101 HTTP requests to the GitHub API. With this refactor, 100 of those HTTP requests have been pushed into the background.

* Allow `gists.starred` to be `NULL`
* Remove getting and saving gist star status from `MyGists::Fetch` and `MyGists::Refresh`
* Add resque gem
* Add `MyGists::Refresh#post_process_gist` to enqueue a gist so its star status can be fetched
* Add `MyGists::Jobs` module as a namespace for all Resque background jobs
* Add `MyGists::Jobs::GistStarStatus` job for asking a class to fetch a gists star status
* Add `MyGists::Fetch::Client` module for defining shared logic used to connect to the GitHub API
* Move `username` and `token` attributes into client mixin
* Refactor `MyGists::Fetch` to include `MyGists::Fetch::Client` module
* Add `MyGists::Fetch::StarStatus`
* Query the GitHub API for a given gist's star status then update the gist's star status
* Update example application yaml
* Noting the need for multiple Redis DSN environment variables, one for caching and one for workers
* Update production environment to use REDIS_CACHE environment variable
* Add Resque initializer to connect resque to Redis
* Add custom `resque:setup` rake task
* Require resque rake tasks
* Declare gists queue
* Setup verbose logging and squash prepared statement PG::Error
* Add `dependent: :destroy` option to user, profile and gist relationships