From 482765e9423333d7a2fbbe8deb3fa25b2ea08943 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 7 Jul 2020 14:40:19 +0200 Subject: [PATCH] Fix assigned counter on inventory items assigning modal [SCI-4840] --- app/services/repository_datatable_service.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/services/repository_datatable_service.rb b/app/services/repository_datatable_service.rb index c7cbd91fc..c975251d3 100644 --- a/app/services/repository_datatable_service.rb +++ b/app/services/repository_datatable_service.rb @@ -40,15 +40,14 @@ class RepositoryDatatableService else 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') + .joins('LEFT OUTER JOIN "my_module_repository_rows" "current_my_module_repository_rows"'\ + 'ON "current_my_module_repository_rows"."repository_row_id" = "repository_rows"."id" '\ + 'AND "current_my_module_repository_rows"."my_module_id" = ' + @my_module.id.to_s) + .where('current_my_module_repository_rows.id IS NOT NULL '\ + 'OR (repository_rows.archived = FALSE AND repositories.archived = FALSE)') + .select('CASE WHEN current_my_module_repository_rows.id IS NOT NULL '\ + 'THEN true ELSE false END as row_assigned') + .group('current_my_module_repository_rows.id') end end repository_rows = repository_rows