Skip to content

Commit

Permalink
Added a function to recompute news score/rank after changes in algori…
Browse files Browse the repository at this point in the history
…thm.
  • Loading branch information
antirez committed Oct 9, 2012
1 parent e039726 commit f2d17cd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app.rb
Expand Up @@ -480,6 +480,25 @@ def render_comment_subthread(comment,sep="")
} }
end 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 # API implementation
############################################################################### ###############################################################################
Expand Down

0 comments on commit f2d17cd

Please sign in to comment.