New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 82832


Ignore:
Timestamp:
08/20/11 18:30:43 (4 years ago)
Author:
derek@…
Message:
  • Use month name and year as hash table key rather than first day of the month
  • When iterating over the past 12 months count away from current month rather than towards it.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/stats-server/app/controllers/ports_controller.rb

    r82157 r82832  
    1818  def populate_monthly_versions(chart_name, chart) 
    1919    chart.string "Month" 
    20      
     20       
    2121    # Add version columns 
    2222    column_order = [] 
     
    8282    now = Time.now 
    8383    now_d = now.to_date 
    84     month_range = (0..11) 
    85          
    86     for i in month_range 
     84     
     85    # Iterate over months from 11 months ago to 0 months ago (current month) 
     86    11.downto(0) do |i| 
    8787      month = now.months_ago(i).to_date 
    8888       
     
    104104    end 
    105105     
    106     key = month.at_beginning_of_month.to_s 
     106    # Key is the abbreviated month name and the year (eg: Aug 2011) 
     107    key = month.to_time.strftime("%b %Y") 
    107108    monthly_installs[key] = entries.size 
    108109  end 
     
    114115      version_entries = entries.where("version = ?", version) 
    115116       
    116       key = month.at_beginning_of_month.to_s 
     117      # Key is the abbreviated month name and the year (eg: Aug 2011) 
     118      key = month.to_time.strftime("%b %Y") 
    117119       
    118120      if monthly_versions[key].nil? 
Note: See TracChangeset for help on using the changeset viewer.