#18 Add sql index for unpublished exercises

And remove spec for remove feature
This commit is contained in:
Maximilian Pass
2020-12-15 12:17:11 +01:00
committed by Felix Auringer
parent 2d2869765f
commit 028fc2989a
13 changed files with 148 additions and 1 deletions

View File

@ -271,3 +271,7 @@ input#subscribe {
.do-not-answer {
background-color: #ea2f1085;
}
#q_submission_study_group_id_in_chosen {
margin-right: 20px;
}

View File

@ -1,6 +1,7 @@
class RequestForCommentsController < ApplicationController
include SubmissionScoring
before_action :set_request_for_comment, only: [:show, :edit, :update, :destroy, :mark_as_solved, :set_thank_you_note]
before_action :set_study_group_grouping, only: %i[index get_my_comment_requests get_rfcs_with_my_comments]
before_action :require_user!
@ -18,8 +19,12 @@ class RequestForCommentsController < ApplicationController
.ransack(params[:q])
@request_for_comments = @search.result
.where("question NOT LIKE '%#loesung%'")
.joins(:exercise)
.where(exercises: {unpublished: false})
.includes(submission: [:study_group])
.order('created_at DESC')
.paginate(page: params[:page], total_entries: @search.result.length)
authorize!
end
@ -125,4 +130,12 @@ class RequestForCommentsController < ApplicationController
params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).merge(user_id: current_user.id, user_type: current_user.class.name)
end
# The index page requires the grouping of the study groups
# The study groups are grouped by the current study group and other study groups of the user
def set_study_group_grouping
current_study_group = StudyGroup.find_by(id: session[:study_group_id])
my_study_groups = current_user.study_groups.reject { |group| group == current_study_group }
@study_groups_grouping = [[t('request_for_comments.index.study_groups.current'), Array(current_study_group)],
[t('request_for_comments.index.study_groups.my'), my_study_groups]]
end
end

View File

@ -8,6 +8,10 @@ h1 = RequestForComment.model_name.human(count: 2)
.form-group
= f.label(:title_cont, t('request_for_comments.solved'), class: 'sr-only')
= f.select(:solved_not_eq, [[t('request_for_comments.show_all'), 2], [t('request_for_comments.show_unsolved'), 1], [t('request_for_comments.show_solved'), 0]])
.form-group
= f.label(:submission_study_group_id_eq, t('request_for_comments.index.study_groups.placeholder'), class: 'sr-only')
= f.grouped_collection_select(:submission_study_group_id_in, @study_groups_grouping, :second, :first, :id, :name, {},
{ class: 'form-control', multiple: true, "data-placeholder": t('request_for_comments.index.study_groups.placeholder') })
.table-responsive
table.table.sortable.mt-4