1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-23 01:16:27 +02:00

Fix Project members SQL query performance issue (#1911)

* Fix sql query

* Update
This commit is contained in:
sjaanus 2022-08-12 16:34:51 +03:00 committed by GitHub
parent b04920602b
commit bf11001d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,11 +250,11 @@ class ProjectStore implements IProjectStore {
async getMembers(projectId: string): Promise<number> {
const rolesFromProject = this.db('role_permission')
.select('role_id')
.distinct()
.where({ project: projectId });
.distinct();
const numbers = await this.db('role_user')
.countDistinct('user_id as members')
.where('project', projectId)
.whereIn('role_id', rolesFromProject)
.first();
const { members } = numbers;