diff --git a/app/helpers/protips_helper.rb b/app/helpers/protips_helper.rb index 1ce07d98..2aee2226 100644 --- a/app/helpers/protips_helper.rb +++ b/app/helpers/protips_helper.rb @@ -298,7 +298,7 @@ def formatted_best_stat_value(protip) value = case best_stat_name(protip).to_sym when :views - best_stat_value(protip) * Protip::COUNTABLE_VIEWS_CHUNK + views_stat_value(protip) else best_stat_value(protip) end @@ -348,4 +348,17 @@ def default_featured_job_banner def protip_display_mode mobile_device? ? "fullpage" : "popup" end + + def views_stat_value(protip) + best_stat_value(protip) * Protip::COUNTABLE_VIEWS_CHUNK + end + + def display_protip_stats?(protip) + stat_name = best_stat_name(protip) + # if stat is present, and the stat we're displaying is views over 50, display. + # otherwise, we're showing stats for something other than views. + return true if protip.best_stat.present? && stat_name == :views && views_stat_value(protip) > 50 + return true if protip.best_stat.present? && stat_name != :views + return false + end end diff --git a/app/views/protips/_mini.html.haml b/app/views/protips/_mini.html.haml index f3473efd..6cecce59 100644 --- a/app/views/protips/_mini.html.haml +++ b/app/views/protips/_mini.html.haml @@ -1,7 +1,7 @@ - protip = protip.load #this is simply a hack, fix ES indexed json %article{:class => dom_class(protip), :id => protip.public_id} - %header - -unless protip.best_stat.nil? || best_stat_value(protip) == 0 + -if display_protip_stats?(protip) + %header %span{:class => protip_stat_class(protip)} = formatted_best_stat_value(protip) unless best_stat_name(protip) =~ /hawt/