Skip to content

Commit

Permalink
Merge pull request #151 from chingu-x/fix/seed-data
Browse files Browse the repository at this point in the history
Update seed data (url input type, end date time)
  • Loading branch information
cherylli authored May 10, 2024
2 parents 7bdaacc + 2c2eb81 commit 6348e22
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ Another example [here](https://co-pilot.dev/changelog)
- Update test github actions workflow with timeout [#143](https://github.com/chingu-x/chingu-dashboard-be/pull/143)
- Refractor of all form title reference to use values from formTitle.ts [#145](https://github.com/chingu-x/chingu-dashboard-be/pull/145)
- Update/Add more form input types [#146](https://github.com/chingu-x/chingu-dashboard-be/pull/146)
- Update seed files (include a time for sprint end dates, add url input type) [#151](https://github.com/chingu-x/chingu-dashboard-be/pull/151)
- Update the deleteFeature method to use a DeleteFeatureResponse and return an object with a successful status and a message [#150](https://github.com/chingu-x/chingu-dashboard-be/pull/150)


### Fixed

- Fix failed tests in app and ideation due to the change from jwt token response to http cookies ([#98](https://github.com/chingu-x/chingu-dashboard-be/pull/98))
Expand Down
6 changes: 3 additions & 3 deletions prisma/seed/forms/voyage-project-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const populateVoyageSubmissionForm = async () => {
order: 3,
inputType: {
connect: {
name: "text",
name: "url",
},
},
text: "Please link your Github repo:",
Expand All @@ -48,7 +48,7 @@ export const populateVoyageSubmissionForm = async () => {
order: 4,
inputType: {
connect: {
name: "text",
name: "url",
},
},
text: "Please link your deployed project:",
Expand All @@ -58,7 +58,7 @@ export const populateVoyageSubmissionForm = async () => {
order: 5,
inputType: {
connect: {
name: "text",
name: "url",
},
},
text: "If you have a project showcase video, please provide the public link:",
Expand Down
9 changes: 9 additions & 0 deletions prisma/seed/responses/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ export const populateQuestionResponses = async (
});
break;
}
case "url": {
await prisma.response.create({
data: {
...data,
text: `https://www.randomUrl${question.id}.com`,
},
});
break;
}
default: {
throw new Error("Prisma seed: Unexpected question type");
}
Expand Down
48 changes: 42 additions & 6 deletions prisma/seed/sprints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,68 @@ export const populateSprints = async () => {
{
number: 1,
startDate: voyage.startDate,
endDate: addDays(voyage.startDate, 6),
endDate: new Date(
addDays(voyage.startDate, 6).setHours(
23,
59,
59,
),
),
},
{
number: 2,
startDate: addDays(voyage.startDate, 7),
endDate: addDays(voyage.startDate, 13),
endDate: new Date(
addDays(voyage.startDate, 13).setHours(
23,
59,
59,
),
),
},
{
number: 3,
startDate: addDays(voyage.startDate, 14),
endDate: addDays(voyage.startDate, 20),
endDate: new Date(
addDays(voyage.startDate, 20).setHours(
23,
59,
59,
),
),
},
{
number: 4,
startDate: addDays(voyage.startDate, 21),
endDate: addDays(voyage.startDate, 27),
endDate: new Date(
addDays(voyage.startDate, 27).setHours(
23,
59,
59,
),
),
},
{
number: 5,
startDate: addDays(voyage.startDate, 28),
endDate: addDays(voyage.startDate, 34),
endDate: new Date(
addDays(voyage.startDate, 34).setHours(
23,
59,
59,
),
),
},
{
number: 6,
startDate: addDays(voyage.startDate, 35),
endDate: addDays(voyage.startDate, 41),
endDate: new Date(
addDays(voyage.startDate, 41).setHours(
23,
59,
59,
),
),
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion prisma/seed/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { prisma } from "../prisma-client";

export const addDays = (date, days) => {
export const addDays = (date, days: number) => {
const newDate = new Date(date);
newDate.setDate(newDate.getDate() + days);
return newDate;
Expand Down
24 changes: 12 additions & 12 deletions prisma/seed/voyage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2023-11-06"),
endDate: new Date("2023-12-17"),
soloProjectDeadline: new Date("2023-11-04"),
certificateIssueDate: new Date("2023-12-31"),
endDate: new Date("2023-12-17T23:59:59.000Z"),
soloProjectDeadline: new Date("2023-11-04T23:59:59.000Z"),
certificateIssueDate: new Date("2023-12-31T23:59:59.000Z"),
},
});

Expand All @@ -25,9 +25,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2024-01-08"),
endDate: new Date("2024-02-18"),
soloProjectDeadline: new Date("2023-12-31"),
certificateIssueDate: new Date("2024-02-25"),
endDate: new Date("2024-02-18T23:59:59.000Z"),
soloProjectDeadline: new Date("2023-12-31T23:59:59.000Z"),
certificateIssueDate: new Date("2024-02-25T23:59:59.000Z"),
},
});
await prisma.voyage.create({
Expand All @@ -39,9 +39,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2024-03-05"),
endDate: new Date("2024-04-14"),
soloProjectDeadline: new Date("2024-02-25"),
certificateIssueDate: new Date("2024-04-21"),
endDate: new Date("2024-04-14T23:59:59.000Z"),
soloProjectDeadline: new Date("2024-02-25T23:59:59.000Z"),
certificateIssueDate: new Date("2024-04-21T23:59:59.000Z"),
},
});
await prisma.voyage.create({
Expand All @@ -53,9 +53,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2024-05-06"),
endDate: new Date("2024-06-16"),
soloProjectDeadline: new Date("2024-04-28"),
certificateIssueDate: new Date("2024-06-23"),
endDate: new Date("2024-06-16T23:59:59.000Z"),
soloProjectDeadline: new Date("2024-04-28T23:59:59.000Z"),
certificateIssueDate: new Date("2024-06-23T23:59:59.000Z"),
},
});
};

0 comments on commit 6348e22

Please sign in to comment.