score:1

well, for starters, you can simplify your code for the same basic approach with the following:

when 'likely1-5'
  (1..5).each do |k|
    v = stats[k.to_s] || 0
    report_collection.push(v.to_i)
  end

score:1

let's see if this works.

question_id = xxx
stats = responseitem.select('score, count(id) as count').
                     where(question_id: question_id).
                     joins('right outer join (select "1" as score union select "2" union select "3" union select "4" union select "5") as scores on score = answer_text').
                     group('score')
scale = stats.reduce({}) do |memo, answer_count|
  memo.merge(answer_count.score.to_i => answer_count.count)
end

Related Query

More Query from same tag