Skip to content

Commit

Permalink
Merge pull request #8535 from ever-co/fix/remove-unnecessary-method
Browse files Browse the repository at this point in the history
[Chore] Remove unnecessary method in project module service
  • Loading branch information
rahul-rocket authored Nov 9, 2024
2 parents c2d62b6 + 69911a2 commit a0af6b3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,6 @@ export class OrganizationProjectModuleController extends CrudController<Organiza
return await this.organizationProjectModuleService.findAll(params);
}

/**
* @description Find project modules by project ID
* @param projectId - The ID of the project to retrieve modules for
* @returns A promise that resolves to a list of modules associated with the project
* @memberof OrganizationProjectModuleController
*/
@ApiOperation({ summary: 'Find project modules by project ID.' })
@ApiResponse({
status: HttpStatus.OK,
description: 'Found project modules for the given project',
type: [OrganizationProjectModule]
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'No modules found for the specified project ID'
})
@Permissions(PermissionsEnum.ALL_ORG_VIEW, PermissionsEnum.PROJECT_MODULE_READ)
@Get('project/:projectId')
async findModulesByProject(
@Param('projectId', UUIDValidationPipe) projectId: ID,
@Query() params: OrganizationProjectModuleFindInputDTO
): Promise<IOrganizationProjectModule[]> {
return await this.organizationProjectModuleService.findModulesByProject(projectId, params);
}

@UseValidationPipe()
@ApiOperation({ summary: 'Find by id' })
@ApiResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,52 +341,6 @@ export class OrganizationProjectModuleService extends TenantAwareCrudService<Org
}
}

/**
* @description Retrieve all modules for a given project
* @param projectId - The ID of the project for which to retrieve modules
* @returns A promise that resolves to the list of project modules
* @memberof OrganizationProjectModuleService
*/
async findModulesByProject(
projectId: ID,
options: IOrganizationProjectModuleFindInput
): Promise<IOrganizationProjectModule[]> {
if (!projectId) {
throw new BadRequestException('Project ID is required');
}
try {
const tenantId = RequestContext.currentTenantId() || options?.tenantId;
const organizationId = options?.organizationId;

// Create query builder
const query = this.typeOrmProjectModuleRepository.createQueryBuilder(this.tableName);

// Joins and where clauses
query.innerJoin(`${query.alias}.members`, 'member');
query.leftJoin(`${query.alias}.teams`, 'project_team');
query.leftJoin(`${query.alias}."organizationSprints"`, 'sprint');

query.andWhere(
new Brackets((qb: WhereExpressionBuilder) => {
qb.andWhere(p(`"${query.alias}"."projectId" = :projectId`), { projectId })
.andWhere(p(`"${query.alias}"."tenantId" = :tenantId`), { tenantId })
.andWhere(p(`"${query.alias}"."organizationId" = :organizationId`), { organizationId });
})
);

console.log('Query to retrieve modules by project:', query.getSql()); // Log query for debugging

// Execute the query
return await query.getMany();
} catch (error) {
// Throw an error if retrieval fails
throw new HttpException(
`Error retrieving modules for project ${projectId}: ${error.message}`,
HttpStatus.BAD_REQUEST
);
}
}

/**
* Apply pagination and query options
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ export class OrganizationProjectModuleService extends CrudService<IOrganizationP
});
}

/**
* Retrieve project modules associated with a specific project.
* @param projectId - The unique identifier of the project.
* @returns An Observable that emits the list of project modules for the specified project.
*/
findModulesByProject(projectId: ID): Observable<IOrganizationProjectModule[]> {
return this.http.get<IOrganizationProjectModule[]>(`${this.API_URL}/project/${projectId}`);
}

/**
* Find a specific project module by its unique identifier.
* @param id - The unique identifier of the project module.
Expand Down

0 comments on commit a0af6b3

Please sign in to comment.