Include access control post when loading uploads in rake task

* to avoid N+1 query
This commit is contained in:
Martin Brennan 2020-02-18 10:35:15 +10:00
parent 59a7afbde9
commit cfd56e9159
1 changed files with 1 additions and 1 deletions

View File

@ -681,7 +681,7 @@ task "uploads:ensure_correct_acl" => :environment do
# #
# Also only get uploads that are not for a theme or a site setting, so only # Also only get uploads that are not for a theme or a site setting, so only
# get post related uploads. # get post related uploads.
uploads_with_supported_media = Upload.includes(:posts, :optimized_images).where( uploads_with_supported_media = Upload.includes(:posts, :access_control_post, :optimized_images).where(
"LOWER(original_filename) SIMILAR TO '%\.(jpg|jpeg|png|gif|svg|ico|mp3|ogg|wav|m4a|mov|mp4|webm|ogv)'" "LOWER(original_filename) SIMILAR TO '%\.(jpg|jpeg|png|gif|svg|ico|mp3|ogg|wav|m4a|mov|mp4|webm|ogv)'"
).joins(:post_uploads) ).joins(:post_uploads)