Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Correctly sort recommendations based on score

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...
commit a0e77bde92d9b035d3e3b00ecc65aa86e4da0205 1 parent f8417c7
@davidcelis authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/recommendable/rater/recommender.rb
View
2  lib/recommendable/rater/recommender.rb
@@ -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 = 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
# Removes an item from a user's set of recommendations
Please sign in to comment.
Something went wrong with that request. Please try again.