From cf18b94326898e8d180d171091c40bd96a198292 Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Tue, 13 May 2014 08:38:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=8F=82=E8=B5=9B=E4=BD=9C=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8C=89=E5=BE=97=E5=88=86=E6=8E=92=E5=BA=8F=EF=BC=9B?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E5=8F=82=E8=B5=9B=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=92=8C=E7=AB=9E=E8=B5=9B=E4=B8=AD=E5=8F=82?= =?UTF-8?q?=E8=B5=9B=E4=BD=9C=E5=93=81=E5=BE=97=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 10 +++++----- app/views/contests/show_attendingcontest.html.erb | 2 +- app/views/softapplications/show.html.erb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 12935d85f..719195cb3 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -336,11 +336,11 @@ class ContestsController < ApplicationController ##取出参赛应用 @softapplication = Softapplication.all @contesting_softapplication = @contest.contesting_softapplications. - joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id"). - joins("LEFT JOIN seems_rateable_cached_ratings ON seems_rateable_cached_ratings.cacheable_id=softapplications.id"). - where("seems_rateable_cached_ratings.cacheable_type='Softapplication'"). - where("seems_rateable_cached_ratings.dimension = 'quality'"). - order("seems_rateable_cached_ratings.avg").reverse_order + joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id"). + joins("LEFT JOIN ( + SELECT * FROM seems_rateable_cached_ratings WHERE cacheable_type='Softapplication' AND DIMENSION = 'quality') AS cached + ON cached.cacheable_id=softapplications.id"). + order("cached.avg").reverse_order @contesting_softapplication = paginateHelper @contesting_softapplication, 10 diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 40f9420bd..834019c8a 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -229,7 +229,7 @@
发布时间:<%= format_time c_softapplication.created_at %> - 最终得分:<%= c_softapplication.softapplication.average(:quality).avg.round(2)%>分 + 最终得分:<%= c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_i.to_s%>分
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb index dcbc45f14..1dfbf0154 100644 --- a/app/views/softapplications/show.html.erb +++ b/app/views/softapplications/show.html.erb @@ -82,7 +82,7 @@
最终得分
-
<%=@softapplication.average(:quality).avg.round(2)%>
+
<%=@softapplication.average(:quality).try(:avg).try(:round, 2).to_i.to_s%>分
<%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %>