Fix user counters on projects overview page [SCI-2847]

This commit is contained in:
Oleksii Kriuchykhin 2018-11-12 11:52:38 +01:00
parent eb72ea69dd
commit 145c66a834

View file

@ -90,14 +90,14 @@ class ProjectsOverviewService
'visibility = 1 OR user_projects.user_id = :user_id', user_id: @user.id 'visibility = 1 OR user_projects.user_id = :user_id', user_id: @user.id
) )
end end
projects = projects projects
.select('projects.*') .select('projects.*')
.select('COUNT(DISTINCT user_projects.id) AS user_count') .select('(SELECT COUNT(DISTINCT user_projects.id) FROM user_projects '\
.select('COUNT(DISTINCT comments.id) AS comment_count') 'WHERE user_projects.project_id = projects.id) AS user_count')
.select('COUNT(DISTINCT due_modules.id) AS notification_count') .select('COUNT(DISTINCT comments.id) AS comment_count')
.group('projects.id') .select('COUNT(DISTINCT due_modules.id) AS notification_count')
.limit(1_000_000) .group('projects.id')
Project.from(projects, 'projects') .limit(1_000_000)
end end
def fetch_dt_records def fetch_dt_records
@ -120,13 +120,13 @@ class ProjectsOverviewService
'visibility = 1 OR user_projects.user_id = :user_id', user_id: @user.id 'visibility = 1 OR user_projects.user_id = :user_id', user_id: @user.id
) )
end end
projects = projects projects
.select('projects.*') .select('projects.*')
.select('COUNT(DISTINCT user_projects.id) AS user_count') .select('(SELECT COUNT(DISTINCT user_projects.id) FROM user_projects '\
.select('COUNT(DISTINCT experiments.id) AS experiment_count') 'WHERE user_projects.project_id = projects.id) AS user_count')
.select('COUNT(DISTINCT my_modules.id) AS task_count') .select('COUNT(DISTINCT experiments.id) AS experiment_count')
.group('projects.id') .select('COUNT(DISTINCT my_modules.id) AS task_count')
Project.from(projects, 'projects') .group('projects.id')
end end
def search(records, value) def search(records, value)