Skip to content

Commit

Permalink
Modified get project detail api
Browse files Browse the repository at this point in the history
  • Loading branch information
Arunesh700 committed Aug 13, 2024
1 parent 4b39580 commit 696c28a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
20 changes: 14 additions & 6 deletions src/controller/progress/tracking.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,21 @@ export class TrackingController {
@Param('projectId') projectId: number,
@Param('moduleId') moduleId: number,
@Req() req,
@Res() res
) {
const res = await this.TrackingService.getProjectDetailsWithStatus(
projectId,
moduleId,
req.user[0].id
);
return res;
try {
let [err, success] = await this.TrackingService.getProjectDetailsWithStatus(
projectId,
moduleId,
req.user[0].id
);
if (err) {
return ErrorResponse.BadRequestException(err.message, err.statusCode).send(res)
}
return new SuccessResponse(success.message, success.statusCode, success.data).send(res);
} catch (error) {
return ErrorResponse.BadRequestException(error.message).send(res);
}
}

@Get('/allBootcampProgress')
Expand Down
20 changes: 13 additions & 7 deletions src/controller/progress/tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ export class TrackingService {
} catch (err) { }
}

async getProjectDetailsWithStatus(projectId: number, moduleId: number, userId: number) {
async getProjectDetailsWithStatus(projectId: number, moduleId: number, userId: number):Promise<any> {
try {
const data = await db.query.zuvyCourseModules.findFirst({
where: (courseModules, { eq }) =>
Expand All @@ -1422,6 +1422,16 @@ export class TrackingService {
projectData: {
where: (projectDetails, { eq }) =>
eq(projectDetails.id, projectId),
with: {
projectTrackingData: {
columns: {
projectLink:true,
isChecked:true,
grades:true
},
where: (projectTrack, { eq }) => eq(projectTrack.userId, userId)
}
}
},
moduleTracking: {
columns: {
Expand All @@ -1438,13 +1448,9 @@ export class TrackingService {
projectData: data['projectData'],
status: data['moduleTracking'].length > 0 ? 'Completed' : 'Pending'
}
return {
status: 'success',
code: 200,
projectDetails
}
return [null,{message:'Project details successfully fetched',statusCode: STATUS_CODES.OK,data:projectDetails}]
} catch (err) {
throw err;
return [{message:err.message,statusCode: STATUS_CODES.BAD_REQUEST}]
}
}

Expand Down

0 comments on commit 696c28a

Please sign in to comment.