Skip to content

Commit

Permalink
Merge pull request #105 from chingu-x/feature/checkin-form-db
Browse files Browse the repository at this point in the history
Update database (question model) for weekly check-in form
  • Loading branch information
cherylli authored Feb 27, 2024
2 parents e19892c + fbf75ac commit 599ccdd
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Another example [here](https://co-pilot.dev/changelog)
- Add Role/Permission guard ([#97](https://github.com/chingu-x/chingu-dashboard-be/pull/97))
- Add e2e tests for auth controller ([#102](https://github.com/chingu-x/chingu-dashboard-be/pull/102))
- Add e2e tests for techs controller (([#103](https://github.com/chingu-x/chingu-dashboard-be/pull/103))
- Add check-in form database implementation and seed data (([#105](https://github.com/chingu-x/chingu-dashboard-be/pull/105))

### Changed
- Update docker compose and scripts in package.json to include a test database container and remove usage of .env.dev to avoid confusion ([#100](https://github.com/chingu-x/chingu-dashboard-be/pull/100))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Question" ADD COLUMN "parentQuestionId" INTEGER;

-- AddForeignKey
ALTER TABLE "Question" ADD CONSTRAINT "Question_parentQuestionId_fkey" FOREIGN KEY ("parentQuestionId") REFERENCES "Question"("id") ON DELETE SET NULL ON UPDATE CASCADE;
37 changes: 20 additions & 17 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -462,23 +462,26 @@ model Form {
}

model Question {
id Int @id @default(autoincrement())
formId Int
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
order Int
inputTypeId Int
inputType InputType @relation(fields: [inputTypeId], references: [id], onDelete: Restrict)
text String
description String?
answerRequired Boolean
multipleAllowed Boolean?
optionGroupId Int?
optionGroup OptionGroup? @relation(fields: [optionGroupId], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz()
updatedAt DateTime @updatedAt
responses Response[]
id Int @id @default(autoincrement())
formId Int
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
order Int
inputTypeId Int
inputType InputType @relation(fields: [inputTypeId], references: [id], onDelete: Restrict)
text String
description String?
answerRequired Boolean
multipleAllowed Boolean?
optionGroupId Int?
optionGroup OptionGroup? @relation(fields: [optionGroupId], references: [id])
parentQuestionId Int?
parentQuestion Question? @relation("QuestionSubQuestion", fields: [parentQuestionId], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz()
updatedAt DateTime @updatedAt
responses Response[]
subQuestions Question[] @relation("QuestionSubQuestion")
}

model InputType {
Expand Down
9 changes: 9 additions & 0 deletions prisma/seed/data/input-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ export default [
{
name: "radio",
},
{
name: "radioGroup",
},
{
name: "checkbox",
},
{
name: "number",
},
{
name: "yesNo",
},
{
name: "teamMembersCheckbox",
},
];
224 changes: 221 additions & 3 deletions prisma/seed/forms/checkinform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const prisma = new PrismaClient();

export const populateCheckinForm = async () => {
// Sprint - checkin form
await prisma.form.create({
const checkinForm = await prisma.form.create({
data: {
formType: {
connect: {
Expand All @@ -20,7 +20,7 @@ export const populateCheckinForm = async () => {
order: 1,
inputType: {
connect: {
name: "text",
name: "radio",
},
},
text: "How did you communicate with your team this past week?",
Expand Down Expand Up @@ -53,7 +53,7 @@ export const populateCheckinForm = async () => {
order: 2,
inputType: {
connect: {
name: "text",
name: "radio",
},
},
text: "Did you contribute to the project for your team this past week?",
Expand Down Expand Up @@ -82,8 +82,226 @@ export const populateCheckinForm = async () => {
},
},
},
{
order: 4,
inputType: {
connect: {
name: "radio",
},
},
text: "How would you rate your team's progress right now?",
answerRequired: true,
optionGroup: {
create: {
name: "checkin-form-progress",
optionChoices: {
createMany: {
data: [
{
text: "We have had a good start!",
},
{
text: "I'm nervous we won't finish",
},
{
text: "It doesn't look good right now",
},
],
},
},
},
},
},
{
order: 5,
inputType: {
connect: {
name: "checkbox",
},
},
text: "What topics did your meetings cover this week? (Select all that apply)",
answerRequired: true,
optionGroup: {
create: {
name: "checkin-meeting-topics",
optionChoices: {
createMany: {
data: [
{
text: "We didn't meet",
},
{
text: "Sprint Review",
},
{
text: "Sprint Retrospective",
},
{
text: "Sprint Planning",
},
{
text: "Other",
},
],
},
},
},
},
},
{
order: 5,
inputType: {
connect: {
name: "yesNo",
},
},
text: "Did you deploy to Production at the end of this Sprint",
answerRequired: true,
},
{
order: 6,
inputType: {
connect: {
name: "teamMembersCheckbox",
},
},
text: "Is there anyone on your team who has not been active? If yes, please select the user. If no, move onto the next question.",
answerRequired: true,
},
{
order: 7,
inputType: {
connect: {
name: "text",
},
},
text: "Please share any personal or team achievements this week here. (ex. held a meeting, teammate got a job, had a pair programming session, learned a valuable team lesson, solved a challenging problem).",
answerRequired: true,
},
{
order: 8,
inputType: {
connect: {
name: "text",
},
},
text: "If a Product Owner has been assigned to your team do you have feed back to share with us about how that's working?",
answerRequired: true,
},
{
order: 9,
inputType: {
connect: {
name: "text",
},
},
text: "If a Voyage Guide has been assigned to your team do you have feed back to share with us about how that's working?",
answerRequired: true,
},
{
order: 10,
inputType: {
connect: {
name: "text",
},
},
text: "Do you have any personal projects you've built that we can showcase in the Weekly Update? (these can be from anytime in your coding history! We want to showcase it!)",
answerRequired: true,
},
{
order: 11,
inputType: {
connect: {
name: "text",
},
},
text: "Please provide any extra other comments, concerns, lessons learned, something you want to learn, etc. here. The more the better since this helps us find ways to support teams & improve the process. Thanks!",
answerRequired: true,
},
],
},
},
});

const radioInput = await prisma.inputType.findUnique({
where: {
name: "radio",
},
});

// add the radio group question
await prisma.question.create({
data: {
form: {
connect: {
id: checkinForm.id,
},
},
order: 3,
inputType: {
connect: {
name: "radioGroup",
},
},
text: "How did you spend time on your project this week?",
answerRequired: true,
optionGroup: {
create: {
name: "time-spent",
optionChoices: {
createMany: {
data: [
{
text: "0 hrs.",
},
{
text: "1-4 hrs.",
},
{
text: "5-8 hrs.",
},
{
text: "8+ hrs.",
},
],
},
},
},
},
subQuestions: {
createMany: {
data: [
{
formId: checkinForm.id,
inputTypeId: radioInput.id,
order: 1,
text: "Pair programming",
answerRequired: true,
},
{
formId: checkinForm.id,
inputTypeId: radioInput.id,
order: 2,
text: "On my own",
answerRequired: true,
},
{
formId: checkinForm.id,
inputTypeId: radioInput.id,
order: 3,
text: "Learning & research",
answerRequired: true,
},
{
formId: checkinForm.id,
inputTypeId: radioInput.id,
order: 4,
text: "Team activities (e.g. meetings, debugging, etc.)",
answerRequired: true,
},
],
},
},
},
});
};

0 comments on commit 599ccdd

Please sign in to comment.