- puts "<h2>Top users editing over the past...</h2>"
- puts "<table>"
- puts "<tr><th>Day</th><th>Week</th><th>Month</th></tr>"
-
- day_users = OldNode.count(:conditions => "timestamp > NOW() - INTERVAL 1 DAY",
- :include => :changeset, :group => :user_id,
- :order => "count_all DESC")
- week_users = OldNode.count(:conditions => "timestamp > NOW() - INTERVAL 7 DAY",
- :include => :changeset, :group => :user_id,
- :order => "count_all DESC", :limit => 60)
- month_users = OldNode.count(:conditions => "timestamp > NOW() - INTERVAL 28 DAY",
- :include => :changeset, :group => :user_id,
- :order => "count_all DESC", :limit => 60)
-
- SyncEnumerator.new(day_users, week_users, month_users).each do |row|
- puts "<tr>"
- row.each do |column|
- if column.nil?
- puts "<td></td>"
- else
- display_name = User.find(column[0]).display_name.gsub('@', ' at ').gsub('.', ' dot ')
- count = column[1]
- puts "<td>#{count} <a href=\"/user/#{display_name}\">#{display_name}</a></td>"
+ puts "<h2>Top users editing over the past...</h2>"
+ puts "<table>"
+ puts "<tr><th>Day</th><th>Week</th><th>Month</th></tr>"
+
+ day_users = OldNode.where("timestamp > NOW() - '1 DAY'::INTERVAL").joins(:changeset).order("count_all DESC").group(:user_id).count
+ week_users = OldNode.where("timestamp > NOW() - '7 DAYS'::INTERVAL").joins(:changeset).order("count_all DESC").limit(60).group(:user_id).count
+ month_users = OldNode.where("timestamp > NOW() - '28 DAYS'::INTERVAL").joins(:changeset).order("count_all DESC").limit(60).group(:user_id).count
+
+ day_users.zip(week_users, month_users).each do |row|
+ puts "<tr>"
+ row.each do |column|
+ if column.nil?
+ puts "<td></td>"
+ else
+ display_name = User.find(column[0]).display_name.gsub('@', ' at ').gsub('.', ' dot ')
+ count = column[1]
+ puts "<td>#{count} <a href=\"/user/#{display_name}\">#{display_name}</a></td>"
+ end