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