Skip to content

Commit

Permalink
メソッドをリファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
djkazunoko committed Jul 19, 2023
1 parent 4adcfa8 commit 63175da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
7 changes: 1 addition & 6 deletions app/helpers/reports_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions app/views/api/practices/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 63175da

Please sign in to comment.