Skip to content

Commit

Permalink
Correctly sort recommendations based on score
Browse files Browse the repository at this point in the history
This is a breaking change, as methods such as `recommended_books` will
no longer be chainable with other ORM query methods.

Signed-off-by: David Celis <me@davidcel.is>
  • Loading branch information
davidcelis committed May 18, 2014
1 parent f8417c7 commit a0e77bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/recommendable/rater/recommender.rb
Expand Up @@ -25,7 +25,7 @@ def recommended_for(klass, count = 10, offset = 0)
ids = Recommendable.redis.zrevrange(recommended_set, offset, count - 1, :with_scores => true) ids = Recommendable.redis.zrevrange(recommended_set, offset, count - 1, :with_scores => true)
ids = ids.select { |id, score| score > 0 }.map { |pair| pair.first } ids = ids.select { |id, score| score > 0 }.map { |pair| pair.first }


Recommendable.query(klass, ids) Recommendable.query(klass, ids).sort_by { |record| ids.index(record.id.to_s) }
end end


# Removes an item from a user's set of recommendations # Removes an item from a user's set of recommendations
Expand Down

0 comments on commit a0e77bd

Please sign in to comment.