Skip to content

Commit

Permalink
インスタンス変数を統一
Browse files Browse the repository at this point in the history
  • Loading branch information
kyokucho1989 committed Dec 12, 2024
1 parent 24d98d1 commit 9db2507
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 22 deletions.
3 changes: 1 addition & 2 deletions app/controllers/api/courses/practices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def index
.includes(practices: [{ started_students: { avatar_attachment: :blob } }, :learning_minute_statistic, :practices_books])
.order('courses_categories.position')
@learnings = current_user.learnings
@user_course_practice = UserCoursePractice.new(current_user)
@completed_practices_size_by_category = @user_course_practice.completed_practices_size_by_category
@completed_practices_size_by_category = @current_user_practice.completed_practices_size_by_category
end
end
1 change: 0 additions & 1 deletion app/controllers/api/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def index
.page(params[:page])
.per(PAGER_NUMBER)
end
@user_course_practice = UserCoursePractice.new(current_user)
end

def show; end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def index
@books = books.with_attached_cover
.includes(:practices)
.order(updated_at: :desc, id: :desc)
@user_course_practice = UserCoursePractice.new(current_user)
end

def new
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/courses/practices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ def index
@course = Course.find(params[:course_id])
@categories = @course.categories.includes(practices: %i[practices_books learning_minute_statistic started_students]).order(:created_at)
@learnings = current_user.learnings
@user_course_practice = UserCoursePractice.new(current_user)
@completed_practices_size_by_category = @user_course_practice.completed_practices_size_by_category
@completed_practices_size_by_category = @current_user_practice.completed_practices_size_by_category
end
end
1 change: 0 additions & 1 deletion app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def index
.latest_update_order
.page(params[:page])
@questions_property = Question.generate_questions_property(params[:target])
@user_course_practice = UserCoursePractice.new(current_user)
end

def show
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ReportsController < ApplicationController
before_action :set_user, only: %i[show]
before_action :set_categories, only: %i[create update]
before_action :set_watch, only: %i[show]
before_action :set_user_course_practice, only: %i[index]

def index
@reports = Report.list.page(params[:page]).per(PAGER_NUMBER)
Expand Down Expand Up @@ -115,10 +114,6 @@ def set_user
@user = User.find_by(id: params[:user_id])
end

def set_user_course_practice
@user_course_practice = UserCoursePractice.new(current_user)
end

def set_check
@check = Check.new
end
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/users/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Users::ReportsController < ApplicationController
before_action :set_reports
before_action :set_report
before_action :set_export
before_action :set_user_course_practice

def index
respond_to do |format|
Expand All @@ -30,10 +29,6 @@ def set_user
@user = User.find(params[:user_id])
end

def set_user_course_practice
@user_course_practice = UserCoursePractice.new(user)
end

def set_reports
@reports = user.reports.list.page(params[:page])
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/users/index.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ json.currentUser do
json.adviser current_user.adviser
json.company_id current_user.company_id
json.admin current_user.admin
json.practices @user_course_practice.sorted_practices
json.practices @current_user_practice.sorted_practices
end

json.target t("target.#{@target}")
Expand Down
2 changes: 1 addition & 1 deletion app/views/books/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nav.page-filter.form
.form-item.is-inline-md-up
= label_tag :practice_id, 'プラクティスで絞り込む', class: 'a-form-label'
= select_tag :practice_id,
options_from_collection_for_select(@user_course_practice.sorted_practices, :id, :title, selected: params[:practice_id]),
options_from_collection_for_select(@current_user_practice.sorted_practices, :id, :title, selected: params[:practice_id]),
include_blank: 'すべての参考書籍を表示',
onchange: 'this.form.submit()',
id: 'js-choices-single-select'
Expand Down
2 changes: 1 addition & 1 deletion app/views/questions/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ header.page-header
= hidden_field_tag :target, params[:target]
= label_tag :practice_id, 'プラクティスで絞り込む', class: 'a-form-label'
= select_tag :practice_id,
options_from_collection_for_select(@user_course_practice.sorted_practices, :id, :title, selected: params[:practice_id]),
options_from_collection_for_select(@current_user_practice.sorted_practices, :id, :title, selected: params[:practice_id]),
include_blank: '全ての質問を表示',
onchange: 'this.form.submit()',
id: 'js-choices-single-select'
Expand Down
2 changes: 1 addition & 1 deletion app/views/reports/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ header.page-header
= form_with url: reports_path, local: true, method: 'get'
.form-item.is-inline-md-up
= label_tag :practice_id, 'プラクティスで絞り込む', class: 'a-form-label'
= select_tag :practice_id, options_from_collection_for_select(@user_course_practice.sorted_practices, :id, :title, selected: params[:practice_id]), include_blank: '全ての日報を表示', onchange: 'this.form.submit()', id: 'js-choices-single-select'
= select_tag :practice_id, options_from_collection_for_select(@current_user_practice.sorted_practices, :id, :title, selected: params[:practice_id]), include_blank: '全ての日報を表示', onchange: 'this.form.submit()', id: 'js-choices-single-select'
hr.a-border
- if @reports.empty?
.o-empty-message
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/reports/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
= render 'users/page_title', user: @user
= user_page_tabs(@user, active_tab: '日報')

= react_component('Reports', userId: @user.id, practices: @user_course_practice.sorted_practices)
= react_component('Reports', userId: @user.id, practices: @current_user_practice.sorted_practices)

0 comments on commit 9db2507

Please sign in to comment.