Skip to content

Commit

Permalink
Merge pull request #8548 from ever-co/fix/improve-find-projects-by-em…
Browse files Browse the repository at this point in the history
…ployee

[Fix]: Improve find projects by employee
  • Loading branch information
rahul-rocket authored Nov 24, 2024
2 parents 362f188 + 9589518 commit 9c42e26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/contracts/src/organization-projects.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface IOrganizationProjectsFindInput
billingFlat?: boolean;
organizationTeamId?: ID;
members?: Partial<IOrganizationProjectEmployeeFindInput>;
relations?: string[];
}

export interface IOrganizationProjectCreateInput extends IOrganizationProjectBase, IMemberEntityBased {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class OrganizationProjectService extends TenantAwareCrudService<Organizat
*/
async findByEmployee(employeeId: ID, input: IOrganizationProjectsFindInput): Promise<IOrganizationProject[]> {
const tenantId = RequestContext.currentTenantId() || input.tenantId; // Use the current tenant ID or fallback to input tenantId
const { organizationId, organizationContactId, organizationTeamId } = input;
const { organizationId, organizationContactId, organizationTeamId, relations = [] } = input;

// Create a query to fetch organization projects
const query = this.typeOrmRepository.createQueryBuilder(this.tableName);
Expand All @@ -327,7 +327,8 @@ export class OrganizationProjectService extends TenantAwareCrudService<Organizat
public: true,
owner: true,
taskListType: true
}
},
relations
});
query.innerJoin(`${query.alias}.members`, 'project_members').leftJoin(`${query.alias}.teams`, 'project_team');
query
Expand Down

0 comments on commit 9c42e26

Please sign in to comment.