added popular exploration, added order:rank

This commit is contained in:
albert
2011-08-11 15:39:51 -04:00
parent bd51079fc1
commit e42ea9c608
25 changed files with 296 additions and 61 deletions

View File

@@ -586,6 +586,10 @@ class Post < ActiveRecord::Base
relation = relation.where("posts.rating <> 'e'")
end
if q[:order] == "rank"
relation = relation.where("p.score > 0 and p.created_at >= ?", 0, 3.days.ago)
end
case q[:order]
when "id", "id_asc"
relation = relation.order("posts.id")
@@ -619,6 +623,9 @@ class Post < ActiveRecord::Base
when "filesize_asc"
relation = relation.order("posts.file_size")
when "rank"
sql << " ORDER BY log(3, p.score) + (extract(epoch from p.created_at) - extract(epoch from timestamp '2005-05-24')) / 45000 DESC"
else
relation = relation.order("posts.id DESC")
end