diff --git a/app/services/repository_datatable_service.rb b/app/services/repository_datatable_service.rb index 66b110245..c7cbd91fc 100644 --- a/app/services/repository_datatable_service.rb +++ b/app/services/repository_datatable_service.rb @@ -38,12 +38,17 @@ class RepositoryDatatableService repository_rows = repository_rows.joins(:my_module_repository_rows) .where(my_module_repository_rows: { my_module_id: @my_module }) else - repository_rows = repository_rows.joins( - 'LEFT OUTER JOIN "my_module_repository_rows" '\ - 'ON "my_module_repository_rows"."repository_row_id" = "repository_rows"."id" '\ - 'AND "my_module_repository_rows"."my_module_id" = ' + @my_module.id.to_s - ).select('CASE WHEN my_module_repository_rows.id IS NOT NULL '\ - 'THEN true ELSE false END as row_assigned').group('my_module_repository_rows.id') + repository_rows = repository_rows + .joins(:repository) + .joins('LEFT OUTER JOIN "my_module_repository_rows" '\ + 'ON "my_module_repository_rows"."repository_row_id" = "repository_rows"."id" '\ + 'AND "my_module_repository_rows"."my_module_id" = ' + @my_module.id.to_s) + .select('CASE WHEN my_module_repository_rows.id IS NOT NULL '\ + 'THEN true ELSE false END as row_assigned') + .where('my_module_repository_rows.id IS NOT NULL + OR (repository_rows.archived = FALSE + AND repositories.archived = FALSE)') + .group('my_module_repository_rows.id') end end repository_rows = repository_rows diff --git a/app/services/repository_rows/my_module_assign_unassign_service.rb b/app/services/repository_rows/my_module_assign_unassign_service.rb index f0a3caa64..cf1e210e3 100644 --- a/app/services/repository_rows/my_module_assign_unassign_service.rb +++ b/app/services/repository_rows/my_module_assign_unassign_service.rb @@ -84,6 +84,7 @@ module RepositoryRows return [] unless params[:rows_to_assign] unassigned_rows = @repository.repository_rows + .active .joins("LEFT OUTER JOIN my_module_repository_rows "\ "ON repository_rows.id = my_module_repository_rows.repository_row_id "\ "AND my_module_repository_rows.my_module_id = #{my_module.id.to_i}")