diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 8e6356201..74f7c074a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -32,8 +32,7 @@ class FilesController < ApplicationController end end - @attachments = @attachments.includes(author: [:user_extension, :course_members]) - .ordered(sort: sort.to_i, sort_type: sort_type.strip) + @attachments = @attachments.ordered(sort: sort.to_i, sort_type: sort_type.strip) @total_count = @attachments.size @unlink_count = @attachments.no_link.size @@ -59,7 +58,8 @@ class FilesController < ApplicationController @attachments = @attachments.no_link end - @attachments = @attachments.page(@page).per(@page_size) + @attachments = @attachments.includes(:course_second_category, author: [:user_extension, :course_members]) + .page(@page).per(@page_size) end def bulk_publish diff --git a/app/views/files/index.json.jbuilder b/app/views/files/index.json.jbuilder index 07430cd7b..f1b3f26d0 100644 --- a/app/views/files/index.json.jbuilder +++ b/app/views/files/index.json.jbuilder @@ -17,7 +17,7 @@ json.data do end # json.partial! "files/course_groups", attachment_group_settings: attachment.attachment_group_settings json.category_id attachment.course_second_category_id - unless @parent_category_id.present? && @parent_category_id != 0 + if (@parent_category_id.blank? || @parent_category_id != 0) && attachment.course_second_category&.parent_id.to_i != 0 json.category_name attachment.course_second_category&.name end end