From 9db25072d9e96c441dd04c5105ba30af8ab36626 Mon Sep 17 00:00:00 2001 From: ko Date: Fri, 13 Dec 2024 05:09:49 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E5=A4=89=E6=95=B0=E3=82=92=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/courses/practices_controller.rb | 3 +-- app/controllers/api/users_controller.rb | 1 - app/controllers/books_controller.rb | 1 - app/controllers/courses/practices_controller.rb | 3 +-- app/controllers/questions_controller.rb | 1 - app/controllers/reports_controller.rb | 5 ----- app/controllers/users/reports_controller.rb | 5 ----- app/views/api/users/index.json.jbuilder | 2 +- app/views/books/index.html.slim | 2 +- app/views/questions/index.html.slim | 2 +- app/views/reports/index.html.slim | 2 +- app/views/users/reports/index.html.slim | 2 +- 12 files changed, 7 insertions(+), 22 deletions(-) diff --git a/app/controllers/api/courses/practices_controller.rb b/app/controllers/api/courses/practices_controller.rb index 06e24fb8753..7cab3d5ffe4 100644 --- a/app/controllers/api/courses/practices_controller.rb +++ b/app/controllers/api/courses/practices_controller.rb @@ -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 diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb index 43c01d2ab76..c8e4549d3e0 100644 --- a/app/controllers/api/users_controller.rb +++ b/app/controllers/api/users_controller.rb @@ -24,7 +24,6 @@ def index .page(params[:page]) .per(PAGER_NUMBER) end - @user_course_practice = UserCoursePractice.new(current_user) end def show; end diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index d2e52ddb2ab..2077eb1eec2 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -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 diff --git a/app/controllers/courses/practices_controller.rb b/app/controllers/courses/practices_controller.rb index 3619122c4ac..63d15537c61 100644 --- a/app/controllers/courses/practices_controller.rb +++ b/app/controllers/courses/practices_controller.rb @@ -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 diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index bddce40f290..783c520e04d 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -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 diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 5018895990f..1de0c33ba1b 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -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) @@ -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 diff --git a/app/controllers/users/reports_controller.rb b/app/controllers/users/reports_controller.rb index d9a477ca162..b74fd4aeb90 100644 --- a/app/controllers/users/reports_controller.rb +++ b/app/controllers/users/reports_controller.rb @@ -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| @@ -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 diff --git a/app/views/api/users/index.json.jbuilder b/app/views/api/users/index.json.jbuilder index 923262c1806..622fd1a552a 100644 --- a/app/views/api/users/index.json.jbuilder +++ b/app/views/api/users/index.json.jbuilder @@ -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}") diff --git a/app/views/books/index.html.slim b/app/views/books/index.html.slim index f5680d47c91..b9f96175802 100644 --- a/app/views/books/index.html.slim +++ b/app/views/books/index.html.slim @@ -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' diff --git a/app/views/questions/index.html.slim b/app/views/questions/index.html.slim index 495436ea577..34b1e7baf01 100644 --- a/app/views/questions/index.html.slim +++ b/app/views/questions/index.html.slim @@ -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' diff --git a/app/views/reports/index.html.slim b/app/views/reports/index.html.slim index 1bb507c0000..11bf20056af 100644 --- a/app/views/reports/index.html.slim +++ b/app/views/reports/index.html.slim @@ -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 diff --git a/app/views/users/reports/index.html.slim b/app/views/users/reports/index.html.slim index b4ccc60be7f..3c7ba361aae 100644 --- a/app/views/users/reports/index.html.slim +++ b/app/views/users/reports/index.html.slim @@ -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)