Module KotobaModel
In: lib/kotoba_model.rb

Methods

Public Class methods

[Source]

    # File lib/kotoba_model.rb, line 29
29:   def self.format_to_thousands(number)
30:     number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
31:   end

[Source]

    # File lib/kotoba_model.rb, line 3
 3:   def self.overview(clazz)
 4:     properties = Array.new
 5:     if ['production'].include?(RAILS_ENV)
 6:       query = "SELECT\nc.language_id language,\ncount(c.id) number_of\nFROM\n\#{clazz.table_name} c\nGROUP BY\nc.language_id\nORDER BY\nnumber_of desc\nLIMIT\n3\n"
 7:       clazz.find_by_sql(query).each{ |record| properties << { :name => Language.find_by_id(record[:language]).language, :value => format_to_thousands(record[:number_of]) } }
 8:     else
 9:       for language_id in [1,2,3]
10:         properties << { :name => Language.find_by_id(language_id).language, :value => format_to_thousands(rand(100000)) }  
11:       end
12:     end
13:     return { :class => clazz.to_s.pluralize.underscore, :title => clazz.human_name, :properties => properties }
14:   end

[Validate]