adrian tried to create a delayed job for the download statistics:
[opensuse:software-o-o.git] / lib / workers / search_helper_job.rb
1
2 class SearchHelperJob
3
4   def initialize
5   end
6
7   def perform
8     time_limit = DateTime.parse 3.months.ago.to_s
9     result = ActiveRecord::Base.connection.execute("select query, count(*) as c from download_histories where query is NOT NULL AND created_at > '#{time_limit}' group by query order by c desc limit 15")
10
11     top = Array.new
12     result.each do |entry|
13       top << { :query => entry[0].strip.downcase, :count => entry[1].to_i}
14     end
15
16     Rails.cache.write('top_downloads', top)
17
18     return top
19   end
20
21 end
22