Permalink
Browse files

Added a function to recompute news score/rank after changes in algori…

…thm.
  • Loading branch information...
1 parent e039726 commit f2d17cd3d131f5723b07bb38e7e69a36a828cda1 @antirez committed Oct 9, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 app.rb
View
19 app.rb
@@ -480,6 +480,25 @@ def render_comment_subthread(comment,sep="")
}
end
+get '/recompute' do
+ if $user and user_is_admin?($user)
+ $r.zrange("news.cron",0,-1).each{|news_id|
+ news = get_news_by_id(news_id)
+ score = compute_news_score(news)
+ rank = compute_news_rank(news)
+ $r.hmset("news:#{news_id}",
+ "score",score,
+ "rank",rank)
+ $r.zadd("news.top",rank,news_id)
+ }
+ H.page {
+ H.p {"Done."}
+ }
+ else
+ redirect "/"
+ end
+end
+
###############################################################################
# API implementation
###############################################################################

0 comments on commit f2d17cd

Please sign in to comment.