diff --git a/app.rb b/app.rb index 205826b..a596233 100644 --- a/app.rb +++ b/app.rb @@ -1603,7 +1603,12 @@ def insert_comment(news_id,user_id,comment_id,parent_id,body) def compute_comment_score(c) upcount = (c['up'] ? c['up'].length : 0) downcount = (c['down'] ? c['down'].length : 0) - upcount-downcount + n = upcount + downcount + return 0 if n==0 + #1.0 = 85%, 1.6 = 95% + z = 1.0 + phat = Float(ups) / n + Math.sqrt(phat+z*z/(2*n)-z*((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n) end # Given a string returns the same string with all the urls converted into