Skip to content

Instantly share code, notes, and snippets.

@therealadam
Created August 21, 2008 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealadam/6597 to your computer and use it in GitHub Desktop.
Save therealadam/6597 to your computer and use it in GitHub Desktop.
window = 14
latest = Time.parse('12:00 AM')
earliest = today - window.days
issues = Issue.find(:conditions => ['updated_at > ? AND updated_at < ?', yesterday, today])
issues_by_day = Hash.new { |key| self[key] = [] }
issues_by_day = issues.injecting(issues_by_day) do |buckets, issue|
buckets[issue.updated_at.strftime('%m/%d')] << issue
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment