Skip to content

Commit

Permalink
extend getById query
Browse files Browse the repository at this point in the history
Join and select public project metadata (this allows to set the
`isPublic` property).
  • Loading branch information
hotzevzl committed Mar 3, 2022
1 parent b9de849 commit 70a7d6f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api/apps/api/src/modules/projects/projects-crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ export class ProjectsCrudService extends AppBaseService<
return entity;
}

extendGetByIdQuery(query: SelectQueryBuilder<Project>, fetchSpecification?: FetchSpecification, info?: ProjectsRequest): SelectQueryBuilder<Project> {
/**
* Bring in publicMetadata (if the project has been made public). This is
* used in the `@AfterLoad()` event listener to set the `isPublic` property
* to true for public projects.
*/
query.leftJoinAndSelect(
'project.publicMetadata',
'publicMetadata'
);

return query;
}

async extendFindAllQuery(
query: SelectQueryBuilder<Project>,
fetchSpecification: FetchSpecification,
Expand All @@ -325,6 +339,9 @@ export class ProjectsCrudService extends AppBaseService<
`${this.alias}.id = acl.project_id`,
);

/**
* @see extendGetByIdQuery()
*/
query.leftJoinAndSelect(
'project.publicMetadata',
'publicMetadata'
Expand Down

0 comments on commit 70a7d6f

Please sign in to comment.