lib/meducation_sdk/services/recommender.rb in meducation_sdk-1.6.4 vs lib/meducation_sdk/services/recommender.rb in meducation_sdk-1.6.5

- old
+ new

@@ -1,16 +1,16 @@ module MeducationSDK class Recommender include Helpers - def self.recommend(item, options = {}) - new(item, options).recommend + def self.recommend(items, options = {}) + new(items, options).recommend end - attr_reader :item - def initialize(item, options = {}) - @item = item + attr_reader :items + def initialize(items, options = {}) + @items = [items].flatten @options = options @limit = options[:limit] || 5 end def recommend @@ -52,10 +52,15 @@ end end end def recommender_json - path = "/#{spi_type_for(item.class.name)}/#{item.id}" + path = "/combined" + separator = "?" + @items.each do |item| + path << separator << "#{spi_type_for(item.class.name)}/#{item.id}" + separator = "&" + end log "Calling #{config.recommender_host}:#{config.recommender_host}#{path}" response = Net::HTTP.get_response(config.recommender_host, path, config.recommender_port) body = response.body log "Received #{body}" body