Skip to content

Commit

Permalink
fix: show profile projects correctly (#3422)
Browse files Browse the repository at this point in the history
Profile projects were not showing correctly in most cases. This fixes
the query to only take into consider whether you have access to the
project (either directly or through a group).

![image](https://user-images.githubusercontent.com/14320932/228598175-874f0daa-8d33-49a8-b6f8-072942876138.png)
  • Loading branch information
nunogois committed Mar 30, 2023
1 parent f60f0a7 commit fbb1280
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/db/project-store.ts
Expand Up @@ -391,14 +391,12 @@ class ProjectStore implements IProjectStore {
}

async getProjectsByUser(userId: number): Promise<string[]> {
const members = await this.db
const projects = await this.db
.from((db) => {
db.select('project')
.from('role_user')
.leftJoin('roles', 'role_user.role_id', 'roles.id')
.where('type', 'root')
.andWhere('name', 'Editor')
.andWhere('user_id', userId)
.where('user_id', userId)
.union((queryBuilder) => {
queryBuilder
.select('project')
Expand All @@ -413,7 +411,7 @@ class ProjectStore implements IProjectStore {
.as('query');
})
.pluck('project');
return members;
return projects;
}

async getMembersCountByProject(projectId: string): Promise<number> {
Expand Down

0 comments on commit fbb1280

Please sign in to comment.