Directly use ActiveRecord object instead of ID

This change will improve the performance by reducing unnecessary SELECT queries.
This commit is contained in:
Sebastian Serth
2023-02-18 19:28:26 +01:00
parent 6465404ebe
commit 40c7a50834
3 changed files with 5 additions and 6 deletions

View File

@ -8,7 +8,7 @@ module FileParameters
next true if file.nil? || file.hidden || file.read_only
# avoid that public files from other contexts can be created
# `next` is similar to an early return and will proceed with the next iteration of the loop
next true if file.context_type == 'Exercise' && file.context_id != exercise.id
next true if file.context_type == 'Exercise' && file.context != exercise
next true if file.context_type == 'Submission' && file.context.user != current_user
next true if file.context_type == 'CommunitySolution' && controller_name != 'community_solutions'