From a1298c18b4b2d79ce928c8b8e5b09a2d4ac9b5a0 Mon Sep 17 00:00:00 2001 From: djkazunoko Date: Wed, 19 Jul 2023 09:13:42 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92?= =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/reports_helper.rb | 7 +------ app/views/api/practices/index.json.jbuilder | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 8805bc453da..2b59ff09f8b 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -11,12 +11,7 @@ def practice_options(categories) def practice_options_within_course user_course_categories = current_user.course.categories.includes(:practices) - user_practices = user_course_categories.flat_map do |category| - category.practices.map do |practice| - [practice.title, practice.id] - end - end - user_practices.uniq + user_course_categories.flat_map(&:practices).map { |practice| [practice.title, practice.id] }.uniq end def convert_to_hour_minute(time) diff --git a/app/views/api/practices/index.json.jbuilder b/app/views/api/practices/index.json.jbuilder index a88c47fdfc2..c1fbb21163b 100644 --- a/app/views/api/practices/index.json.jbuilder +++ b/app/views/api/practices/index.json.jbuilder @@ -1,10 +1,6 @@ # frozen_string_literal: true -user_practices = @categories.flat_map do |category| - category.practices -end - -unique_practices = user_practices.uniq +unique_practices = @categories.flat_map(&:practices).uniq json.array! unique_practices do |practice| json.(practice, :id, :title)