From 7565fc5fc2aabf47db1fd5a439741306365b8e6b Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 16 Sep 2025 14:56:45 +0200 Subject: [PATCH] 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. --- app/components/admin/poll/results/question_component.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/components/admin/poll/results/question_component.rb b/app/components/admin/poll/results/question_component.rb index 2b14743ce..c12d9d344 100644 --- a/app/components/admin/poll/results/question_component.rb +++ b/app/components/admin/poll/results/question_component.rb @@ -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