lib/picky/query/allocation.rb in picky-4.6.0 vs lib/picky/query/allocation.rb in picky-4.6.1

- old
+ new

@@ -21,35 +21,38 @@ # # def initialize index, combinations @combinations = combinations - # TODO Could this be rewritten? + # THINK Could this be rewritten? # @result_identifier = index.result_identifier @backend = index.backend end # Asks the backend for the total score and # adds the boosts to it. # - # TODO THINK Can the combinations be empty? + # Note: Combinations can be empty on eg. + # query "alan history" and category :title is + # ignored (ie. removed). # def calculate_score weights - @score ||= if @combinations.empty? - 0 - else - @backend.weight(@combinations) + - @combinations.boost_for(weights) - end + @score ||= if @combinations.empty? + 0 # Optimization. + else + @backend.weight(@combinations) + @combinations.boost_for(weights) + end end # Asks the backend for the (intersected) ids. # - # TODO THINK Can the combinations be empty? + # Note: Combinations can be empty on eg. + # query "alan history" and category :title is + # ignored (ie. removed). # def calculate_ids amount, offset - return [] if @combinations.empty? + return [] if @combinations.empty? # Checked here to avoid checking in each backend. @backend.ids @combinations, amount, offset end # Ids return by default []. # \ No newline at end of file