Reduce SQL queries for RfC index actions

By using includes and carefully selecting objects through references, all required objects are only queried once.
This commit is contained in:
Sebastian Serth
2023-02-20 09:36:35 +01:00
parent 76f592c88d
commit d0717fb178
2 changed files with 13 additions and 8 deletions

View File

@ -40,7 +40,7 @@ h1 = RequestForComment.model_name.human(count: 2)
span class="fa-solid fa-check" style="color:darkgrey" aria-hidden="true"
- else
td = ''
td = link_to_if(policy(request_for_comment).show?, request_for_comment.exercise.title, request_for_comment)
td = link_to_if(policy(request_for_comment).show?, request_for_comment.submission.exercise.title, request_for_comment)
- if request_for_comment.has_attribute?(:question) && request_for_comment.question.present?
td = truncate(request_for_comment.question, length: 200)
- else