-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from chingu-x/feature/voyage-submission
Feature/voyage submission
- Loading branch information
Showing
20 changed files
with
731 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
prisma/migrations/20240414140948_add_voyage_project_submission_table/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- CreateTable | ||
CREATE TABLE "FormResponseVoyageProject" ( | ||
"id" SERIAL NOT NULL, | ||
"voyageTeamId" INTEGER NOT NULL, | ||
"responseGroupId" INTEGER NOT NULL, | ||
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "FormResponseVoyageProject_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "FormResponseVoyageProject_voyageTeamId_key" ON "FormResponseVoyageProject"("voyageTeamId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "FormResponseVoyageProject_responseGroupId_key" ON "FormResponseVoyageProject"("responseGroupId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FormResponseVoyageProject" ADD CONSTRAINT "FormResponseVoyageProject_voyageTeamId_fkey" FOREIGN KEY ("voyageTeamId") REFERENCES "VoyageTeam"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FormResponseVoyageProject" ADD CONSTRAINT "FormResponseVoyageProject_responseGroupId_fkey" FOREIGN KEY ("responseGroupId") REFERENCES "ResponseGroup"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { prisma } from "../prisma-client"; | ||
import { getQuestionsByFormTitle, populateQuestionResponses } from "./helper"; | ||
import { FormTitles } from "../../../src/global/constants/formTitles"; | ||
|
||
export const populateCheckinFormResponse = async () => { | ||
const teamMemberId = 1; | ||
const teamMember = await prisma.voyageTeamMember.findUnique({ | ||
where: { | ||
id: teamMemberId, | ||
}, | ||
select: { | ||
id: true, | ||
voyageTeam: { | ||
select: { | ||
voyage: { | ||
select: { | ||
sprints: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
// get questions | ||
const questions = await getQuestionsByFormTitle(FormTitles.sprintCheckin); | ||
|
||
const responseGroup = await prisma.responseGroup.create({ | ||
data: {}, | ||
}); | ||
|
||
await Promise.all( | ||
questions.map((question) => { | ||
populateQuestionResponses(question, responseGroup.id, teamMemberId); | ||
}), | ||
); | ||
|
||
await prisma.formResponseCheckin.create({ | ||
data: { | ||
voyageTeamMemberId: teamMember.id, | ||
sprintId: teamMember.voyageTeam.voyage.sprints[0].id, | ||
responseGroupId: responseGroup.id, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { prisma } from "../prisma-client"; | ||
import { FormTitles } from "../../../src/global/constants/formTitles"; | ||
import { getQuestionsByFormTitle, populateQuestionResponses } from "./helper"; | ||
|
||
export const populateVoyageProjectSubmissionFormResponses = async () => { | ||
const voyageTeamId = 1; //hardcoded voyage team Id | ||
|
||
const questions = await getQuestionsByFormTitle( | ||
FormTitles.voyageProjectSubmission, | ||
); | ||
|
||
const responseGroup = await prisma.responseGroup.create({ | ||
data: {}, | ||
}); | ||
|
||
await Promise.all( | ||
questions.map((question) => { | ||
populateQuestionResponses(question, responseGroup.id); | ||
}), | ||
); | ||
|
||
await prisma.formResponseVoyageProject.create({ | ||
data: { | ||
voyageTeamId: voyageTeamId, | ||
responseGroupId: responseGroup.id, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.