Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Remove unnecessary method in project module service #8535

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading