Skip to content

Commit fb5b4ef

Browse files
committed
Reduce SQL queries for RfC show action
1 parent 730de65 commit fb5b4ef

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

app/controllers/request_for_comments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def create
164164

165165
# Use callbacks to share common setup or constraints between actions.
166166
def set_request_for_comment
167-
@request_for_comment = RequestForComment.find(params[:id])
167+
@request_for_comment = RequestForComment.includes(:exercise, :user, submission: [:study_group, {files: [:file_type], testruns: [:testrun_messages, {file: [:file_type]}]}]).find(params[:id])
168168
end
169169

170170
def request_for_comment_params

app/views/request_for_comments/show.html.slim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
p.list-group-item-text
99
- user = @request_for_comment.user
1010
- submission = @request_for_comment.submission
11-
- testruns = Testrun.where(submission_id: @request_for_comment.submission)
11+
- testruns = submission.testruns
1212
= link_to_if(policy(user).show?, user.displayname, user)
1313
| | #{@request_for_comment.created_at.localtime}
1414
- if @request_for_comment.submission.study_group.present? && policy(@request_for_comment.submission).show_study_group?
@@ -71,7 +71,7 @@
7171
| do not put a carriage return in the line below. it will be present in the presentation of the source code, otherwise.
7272
| also, all settings from the rails model needed for the editor configuration in the JavaScript are attached to the editor as data attributes here.
7373
- submission.files.each do |file|
74-
= "#{file.path || ''}/#{file.name}#{file.file_type.file_extension}"
74+
= file.filepath
7575
br
7676
|   
7777
i.fa-solid.fa-arrow-down aria-hidden='true'

0 commit comments

Comments
 (0)