Module: Coletivo::Models::Recommendable::ClassMethods
- Defined in:
- lib/coletivo/models/recommendable.rb
Instance Method Summary collapse
- #find_recommendations_for(person, options = {}) ⇒ Object
- #load_preferences_for_recommendation(person) ⇒ Object
- #map_ratings_to_preferences(ratings) ⇒ Object
Instance Method Details
#find_recommendations_for(person, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/coletivo/models/recommendable.rb', line 10 def find_recommendations_for(person, = {}) preferences = [:preferences] ||= load_preferences_for_recommendation(person) top = (person, preferences, ) ids = top.collect(&:last) where(:id => ids).limit([:limit]).all end |
#load_preferences_for_recommendation(person) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/coletivo/models/recommendable.rb', line 32 def load_preferences_for_recommendation(person) r = Coletivo::Config. \ .find_for_recommendation(person, self) (r) end |
#map_ratings_to_preferences(ratings) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/coletivo/models/recommendable.rb', line 19 def () #TODO: (???) Item based mapping. key, subkey = :person_id, :rateable_id preferences = {} .each do || p = preferences[.send(key)] ||= {} p[.send(subkey)] = .weight end preferences end |