|
|
|
@ -40,8 +40,25 @@ class SoftapplicationsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# GET /softapplications/1
|
|
|
|
|
# GET /softapplications/1.json
|
|
|
|
|
|
|
|
|
|
def percent_of(num, percent)
|
|
|
|
|
num.to_f / percent.to_f * 100.0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
@softapplication = Softapplication.find(params[:id])
|
|
|
|
|
# 打分统计
|
|
|
|
|
stars_reates = @softapplication.
|
|
|
|
|
rates(:quality)
|
|
|
|
|
stars_reates_count = stars_reates.count == 0 ? 1 : stars_reates.count
|
|
|
|
|
stars_status = stars_reates.select("stars, count(*) as scount").
|
|
|
|
|
group("stars")
|
|
|
|
|
|
|
|
|
|
@stars_status_map = Hash.new(0.0)
|
|
|
|
|
stars_status.each do |star_status|
|
|
|
|
|
@stars_status_map["star#{star_status.stars.to_i}".to_sym] =
|
|
|
|
|
percent_of(star_status.scount, stars_reates_count).to_s + "%"
|
|
|
|
|
end
|
|
|
|
|
@jours = @softapplication.journals_for_messages.order('created_on DESC')
|
|
|
|
|
@image_results = []
|
|
|
|
|
@softapplication.attachments.each do |f|
|
|
|
|
|