Remove redundant by_question grouping in Admin::Poll::Results::QuestionComponent

Stop grouping partial results by question_id inside the component.

Note that group_by on an empty collection already returns
an empty hash, so the previous "|| {}" is not needed.
This commit is contained in:
taitus
2025-09-16 14:56:45 +02:00
parent 5945bfe9ed
commit 7565fc5fc2

View File

@@ -7,12 +7,6 @@ class Admin::Poll::Results::QuestionComponent < ApplicationComponent
end
def by_answer
@by_answer ||= by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {}
@by_answer ||= partial_results.where(question: question).group_by(&:answer)
end
private
def by_question
@by_question ||= partial_results.group_by(&:question_id)
end
end