Last active
January 1, 2016 00:49
-
-
Save mostafahussein/8069191 to your computer and use it in GitHub Desktop.
This file contains 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
first_day = Ticket.minimum(:created_at).to_date | |
last_day = Ticket.maximum(:created_at).to_date | |
all_tickets = Ticket.all # or Ticket.where(created_at: <from>..<to>) | |
count_by_day = (first_day..last_day).map do |day| | |
[ day, all_tickets.select{|t| t.created_at.to_date == day }.count ] | |
end | |
hash_version = Hash[ count_by_day ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment