From df3ae184f9b8aa4baa7e2e6e6635a8e3c32d25f0 Mon Sep 17 00:00:00 2001
From: Robin Ward <robin.ward@gmail.com>
Date: Fri, 29 Mar 2013 12:54:16 -0400
Subject: [PATCH] Fix: `best_of` flag was not being updated properly

---
 lib/score_calculator.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb
index e35bf99bc..74cfa94f0 100644
--- a/lib/score_calculator.rb
+++ b/lib/score_calculator.rb
@@ -34,10 +34,10 @@ class ScoreCalculator
     exec_sql "UPDATE topics AS t
               SET has_best_of = (t.like_count >= :likes_required AND
                                  t.posts_count >= :posts_required AND
-                                 x.min_score >= :score_required),
+                                 x.max_score >= :score_required),
                   score = x.avg_score
               FROM (SELECT p.topic_id,
-                           MIN(p.score) AS min_score,
+                           MAX(p.score) AS max_score,
                            AVG(p.score) AS avg_score
                     FROM posts AS p
                     GROUP BY p.topic_id) AS x