public
Fork of choonkeat/poormans-trends
Description: Plug and play trend visualisation for your data.
Homepage: http://blog.choonkeat.com/weblog/2008/04/poor-mans-trend.html
Clone URL: git://github.com/dustin/poormans-trends.git
Search Repo:
bugfix: selection for "top_values" in foreign keys by limiting 
correct weeks
choonkeat (author)
Thu Apr 17 00:52:57 -0700 2008
commit  6c5117cec0f9387f08e3a5c0a659c667d74c7804
tree    85b47d707d2ad6e961e9326d60e2c7e8b4060546
parent  16e587e2979f3dd70ab0b66c9c3fb419940d4700
...
44
45
46
47
 
48
49
50
...
44
45
46
 
47
48
49
50
0
@@ -44,7 +44,7 @@ module Poormans
0
           @columns.each do |col|
0
             @top_values[col] = klass.find(:all, {
0
               :select => "COUNT(*) as #{col}_count, #{col}",
0
- :conditions => "DATEDIFF(NOW(), #{date_col}) < 8 ",
0
+ :conditions => ["FLOOR(DATEDIFF(NOW(), #{date_col}) / 7) <= ?", @max_cols],
0
               :group => col,
0
               :order => "#{col}_count DESC",
0
               :limit => @max_rows,
...
9
10
11
12
 
13
14
15
...
19
20
21
22
 
23
24
25
...
9
10
11
 
12
13
14
15
...
19
20
21
 
22
23
24
25
0
@@ -9,7 +9,7 @@
0
     <% @top_values[col][0..0].each do |hash| %>
0
       <tr>
0
         <td>weeks ago</td>
0
- <% (0..@max_cols-1).to_a.reverse.each do |val| %>
0
+ <% (0..@max_cols).to_a.reverse.each do |val| %>
0
         <th id="<%= col %>_<%= val %>"><%= val %></th>
0
        <% end %>
0
       </tr>
0
@@ -19,7 +19,7 @@
0
     <% @top_values[col].each do |hash| %>
0
       <tr>
0
         <th headers="members"><%=h hash.keys.first || 'nil' %></th>
0
- <% (0..@max_cols-1).to_a.reverse.each do |val| %>
0
+ <% (0..@max_cols).to_a.reverse.each do |val| %>
0
         <td headers="<%= col %>_<%= val %>"><%=h hash.values.first[val.to_s] || 0 %></td>
0
        <% end %>
0
       </tr>

Comments

    No one has commented yet.