molten-trunk/molten5_withgrid/app/models/sfsolution.rb
# Returns a 2-D Array with:
#   - The friendly name of the rating
#   - The actual attribute name
#   - The number of votes.
Returns a 2-D Array with:
The friendly name of the rating
The actual attribute name
The number of votes.
Returns a 2 - D Array with : The friendly name of the rating The actual attribute name The number of votes .
def list_ratings
    final_result = []
    rating_results = rating.count_attributes.to_a
    ordered_results = []
    ['one', 'two', 'three', 'four'].each do |order|
      rating_results.each do |result|
        if order == result[0]
          ordered_results << result
        end
      end
    end
    for i in 0...ordered_results.length
      final_result << [AppConstants::FRIENDLY_RATING_NAMES[i],ordered_results[i][0],(ordered_results[i][1].to_f/total_votes.to_f)*100]
    end
    final_result
  end
def list_ratings final_result = [ ] rating_results = rating . count_attributes . to_a ordered_results = [ ] [ 'one' , 'two' , 'three' , 'four' ] . each do | order | rating_results . each do | result | if order == result [ 0 ] ordered_results << result end end end for i in 0 ... ordered_results . length final_result << [ AppConstants :: FRIENDLY_RATING_NAMES [ i ] , ordered_results [ i ] [ 0 ] , ( ordered_results [ i ] [ 1 ] . to_f / total_votes . to_f ) * 100 ] end final_result end
Returns a 2-D Array with:
 The friendly name of the rating
 The actual attribute name
 The number of votes.
Returns a 2 - D Array with : The friendly name of the rating The actual attribute name The number of votes .
# grab all of the rating attributes and counts and turn them into an array # order the rating counts and attributes # add in the friendly name