Created
March 14, 2010 07:14
-
-
Save tonyarnold/331818 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def revenue_history_months | |
| limit = 12 | |
| @orders = Order.find(:all, :conditions => ["status = 'C' and lower(payment_type) != 'free' and order_time >= ?", limit.months.ago]) | |
| @orders_months = @orders.group_by { |m| m.order_time.beginning_of_month } | |
| values = [] | |
| @orders_months.each {| month, order | | |
| monthly_total = 0; | |
| order.each { |o| | |
| monthly_total += o.total | |
| } | |
| values << "[#{month.to_date.to_time.to_i*1000}, #{monthly_total}]" | |
| } | |
| values_str = values.join(", ").strip | |
| render :js => "$(function () { drawGraph([#{values_str}], 'month'); });" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment