Merge pull request #2683 from mlorb/ml-sci-4742

Hide archived and not assigned items … [SCI-4742]
This commit is contained in:
Alex Kriuchykhin 2020-06-24 13:47:22 +02:00 committed by GitHub
commit 2125c8bf83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -38,12 +38,17 @@ class RepositoryDatatableService
repository_rows = repository_rows.joins(:my_module_repository_rows) repository_rows = repository_rows.joins(:my_module_repository_rows)
.where(my_module_repository_rows: { my_module_id: @my_module }) .where(my_module_repository_rows: { my_module_id: @my_module })
else else
repository_rows = repository_rows.joins( repository_rows = repository_rows
'LEFT OUTER JOIN "my_module_repository_rows" '\ .joins(:repository)
.joins('LEFT OUTER JOIN "my_module_repository_rows" '\
'ON "my_module_repository_rows"."repository_row_id" = "repository_rows"."id" '\ 'ON "my_module_repository_rows"."repository_row_id" = "repository_rows"."id" '\
'AND "my_module_repository_rows"."my_module_id" = ' + @my_module.id.to_s 'AND "my_module_repository_rows"."my_module_id" = ' + @my_module.id.to_s)
).select('CASE WHEN my_module_repository_rows.id IS NOT NULL '\ .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') '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
end end
repository_rows = repository_rows repository_rows = repository_rows

View file

@ -84,6 +84,7 @@ module RepositoryRows
return [] unless params[:rows_to_assign] return [] unless params[:rows_to_assign]
unassigned_rows = @repository.repository_rows unassigned_rows = @repository.repository_rows
.active
.joins("LEFT OUTER JOIN my_module_repository_rows "\ .joins("LEFT OUTER JOIN my_module_repository_rows "\
"ON repository_rows.id = my_module_repository_rows.repository_row_id "\ "ON repository_rows.id = my_module_repository_rows.repository_row_id "\
"AND my_module_repository_rows.my_module_id = #{my_module.id.to_i}") "AND my_module_repository_rows.my_module_id = #{my_module.id.to_i}")