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 |
# 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.in => ids).limit([:limit]).all end |
#load_preferences_for_recommendation(person) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/coletivo/models/recommendable.rb', line 31 def load_preferences_for_recommendation(person) r = Coletivo::Config. \ .find_for_recommendation(person, self) (r) end |
#map_ratings_to_preferences(ratings) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/coletivo/models/recommendable.rb', line 18 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 |