I am trying to get hourly counts of orders between different price ranges from my database. I'm thinking there has got to be a better way than looping through each record and checking if the created_at time fits between hour 1, 2, 3, 4, etc of the day and then returning the count.
Currently I am displaying just a total of the days sales that are between different dollar amounts this way: In my controller I grab all orders that are from today and return those to the view as @orders In my view I display the number sold that are in a particular price range by the following helper method: def number_between_75_and_100_sold count = 0 for n in @orders if n.total >= 75 && n.total < 100 count = count + 1 end end return count end This helper method feels ugly to me. I have 3 others that give me different order total ranges. Better way? If I use this same logic to count sales per hour I am going to end up with 24 more helpers that count those sales for each hour by looking at created_at times between a range. This is going to be slow, ugly and lame. I appreciate any advice. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.