-
Notifications
You must be signed in to change notification settings - Fork 67
Fix undefined subcontrols #1321
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { getAllProjectsQuery, updateProjectUpdatedByIdQuery } from "../utils/pro | |||||||||||||||||||||||||||||||||||||||
| import { RequestWithFile, UploadedFile } from "../utils/question.utils"; | ||||||||||||||||||||||||||||||||||||||||
| import { STATUS_CODE } from "../utils/statusCode.utils"; | ||||||||||||||||||||||||||||||||||||||||
| import { QuestionStructEU } from "../models/EU/questionStructEU.model"; | ||||||||||||||||||||||||||||||||||||||||
| import { countAnswersEUByProjectId, countSubControlsEUByProjectId, deleteAssessmentEUByProjectIdQuery, deleteComplianeEUByProjectIdQuery, getAllControlCategoriesQuery, getAllTopicsQuery, getAssessmentsEUByProjectIdQuery, getComplianceEUByProjectIdQuery, getControlByIdForProjectQuery, getControlStructByControlCategoryIdQuery, getTopicByIdForProjectQuery, updateControlEUByIdQuery, updateQuestionEUByIdQuery, updateSubcontrolEUByIdQuery } from "../utils/eu.utils"; | ||||||||||||||||||||||||||||||||||||||||
| import { countAnswersEUByProjectId, countSubControlsEUByProjectId, deleteAssessmentEUByProjectIdQuery, deleteComplianeEUByProjectIdQuery, getAllControlCategoriesQuery, getAllTopicsQuery, getAssessmentsEUByProjectIdQuery, getComplianceEUByProjectIdQuery, getControlByIdForProjectQuery, getControlStructByControlCategoryIdForAProjectQuery, getControlStructByControlCategoryIdQuery, getTopicByIdForProjectQuery, updateControlEUByIdQuery, updateQuestionEUByIdQuery, updateSubcontrolEUByIdQuery } from "../utils/eu.utils"; | ||||||||||||||||||||||||||||||||||||||||
| import { AnswerEU } from "../models/EU/answerEU.model"; | ||||||||||||||||||||||||||||||||||||||||
| import { sequelize } from "../database/db"; | ||||||||||||||||||||||||||||||||||||||||
| import { Project, ProjectModel } from "../models/project.model"; | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -292,8 +292,8 @@ export async function getProjectAssessmentProgress(req: Request, res: Response) | |||||||||||||||||||||||||||||||||||||||
| const { totalAssessments, answeredAssessments } = await countAnswersEUByProjectId(projectFrameworkId); | ||||||||||||||||||||||||||||||||||||||||
| return res.status(200).json( | ||||||||||||||||||||||||||||||||||||||||
| STATUS_CODE[200]({ | ||||||||||||||||||||||||||||||||||||||||
| totalQuestions: totalAssessments, | ||||||||||||||||||||||||||||||||||||||||
| answeredQuestions: answeredAssessments, | ||||||||||||||||||||||||||||||||||||||||
| totalQuestions: parseInt(totalAssessments), | ||||||||||||||||||||||||||||||||||||||||
| answeredQuestions: parseInt(answeredAssessments), | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -313,8 +313,8 @@ export async function getProjectComplianceProgress(req: Request, res: Response) | |||||||||||||||||||||||||||||||||||||||
| const { totalSubcontrols, doneSubcontrols } = await countSubControlsEUByProjectId(projectFrameworkId); | ||||||||||||||||||||||||||||||||||||||||
| return res.status(200).json( | ||||||||||||||||||||||||||||||||||||||||
| STATUS_CODE[200]({ | ||||||||||||||||||||||||||||||||||||||||
| allsubControls: totalSubcontrols, | ||||||||||||||||||||||||||||||||||||||||
| allDonesubControls: doneSubcontrols, | ||||||||||||||||||||||||||||||||||||||||
| allsubControls: parseInt(totalSubcontrols), | ||||||||||||||||||||||||||||||||||||||||
| allDonesubControls: parseInt(doneSubcontrols), | ||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -412,7 +412,8 @@ export async function getControlsByControlCategoryId( | |||||||||||||||||||||||||||||||||||||||
| ): Promise<any> { | ||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||
| const controlCategoryId = parseInt(req.params.id); | ||||||||||||||||||||||||||||||||||||||||
| const controls = await getControlStructByControlCategoryIdQuery(controlCategoryId); | ||||||||||||||||||||||||||||||||||||||||
| const projectFrameworkId = parseInt(req.query.projectFrameworkId as string); | ||||||||||||||||||||||||||||||||||||||||
| const controls = await getControlStructByControlCategoryIdForAProjectQuery(controlCategoryId, projectFrameworkId); | ||||||||||||||||||||||||||||||||||||||||
| return res.status(200).json(controls); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
414
to
417
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added project framework filtering to control retrieval. The function now accepts a You should add validation for the try {
const controlCategoryId = parseInt(req.params.id);
const projectFrameworkId = parseInt(req.query.projectFrameworkId as string);
+ if (isNaN(projectFrameworkId)) {
+ return res.status(400).json(STATUS_CODE[400]("Invalid projectFrameworkId"));
+ }
const controls = await getControlStructByControlCategoryIdForAProjectQuery(controlCategoryId, projectFrameworkId);
return res.status(200).json(controls);
} catch (error) {📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||
| return res.status(500).json(STATUS_CODE[500]((error as Error).message)); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. Now we could move the logic inside this useEffect to its hook, useControls, and call it here to obtain
controls.