Skip to content

Commit

Permalink
Add seeds of tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
canjalal committed Nov 5, 2024
1 parent a19c064 commit c375b83
Showing 1 changed file with 142 additions and 4 deletions.
146 changes: 142 additions & 4 deletions src/backend/db/lib/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const seedfile = async (databaseUrl: string) => {
.select("user_id")
.executeTakeFirstOrThrow();

await db
const { student_id: student_1_id } = await db
.insertInto("student")
.values({
first_name: "Edna",
Expand All @@ -20,9 +20,10 @@ export const seedfile = async (databaseUrl: string) => {
grade: 1,
assigned_case_manager_id: firstuser.user_id,
})
.execute();
.returning("student_id")
.executeTakeFirstOrThrow();

await db
const { student_id: student_2_id } = await db
.insertInto("student")
.values({
first_name: "Colette",
Expand All @@ -31,7 +32,8 @@ export const seedfile = async (databaseUrl: string) => {
grade: 2,
assigned_case_manager_id: firstuser.user_id,
})
.execute();
.returning("student_id")
.executeTakeFirstOrThrow();

await db
.insertInto("student")
Expand Down Expand Up @@ -64,5 +66,141 @@ export const seedfile = async (databaseUrl: string) => {
})
.execute();

const { iep_id: student_1_iep_id } = await db
.insertInto("iep")
.values({
case_manager_id: firstuser.user_id,
student_id: student_1_id,
start_date: new Date("2024-11-05"),
end_date: new Date("2028-12-31"),
})
.returning("iep_id")
.executeTakeFirstOrThrow();

const { iep_id: student_2_iep_id } = await db
.insertInto("iep")
.values({
case_manager_id: firstuser.user_id,
student_id: student_2_id,
start_date: new Date("2024-11-04"),
end_date: new Date("2028-12-30"),
})
.returning("iep_id")
.executeTakeFirstOrThrow();

const { goal_id: student_1_goal_1_id } = await db
.insertInto("goal")
.values({
iep_id: student_1_iep_id,
description: "Improve Spanish grade",
category: "other",
})
.returning("goal_id")
.executeTakeFirstOrThrow();

const { goal_id: student_1_goal_2_id } = await db
.insertInto("goal")
.values({
iep_id: student_1_iep_id,
description: "Come to class more punctually",
category: "other",
})
.returning("goal_id")
.executeTakeFirstOrThrow();

const { goal_id: student_2_goal_id } = await db
.insertInto("goal")
.values({
iep_id: student_2_iep_id,
description: "Organize notebook",
category: "other",
})
.returning("goal_id")
.executeTakeFirstOrThrow();

const { benchmark_id: benchmark_student_1_goal_1_id } = await db
.insertInto("benchmark")
.values({
goal_id: student_1_goal_1_id,
status: "In Progress",
description: "Create example sentences from vocab",
setup: "Make Google Sheets from vocab list",
instructions:
"Have student create example sentences for each vocab word in Google Sheets",
materials: "N/A",
frequency: "Once per week",
target_level: 60,
baseline_level: 0,
attempts_per_trial: 1,
number_of_trials: 16,
metric_name: "",
})
.returning("benchmark_id")
.executeTakeFirstOrThrow();

await db
.insertInto("task")
.values({
benchmark_id: benchmark_student_1_goal_1_id,
assignee_id: firstuser.user_id,
})
.execute();

const { benchmark_id: benchmark_student_1_goal_2_id } = await db
.insertInto("benchmark")
.values({
goal_id: student_1_goal_2_id,
status: "In Progress",
description: "Create morning schedule",
setup: "Make Google Sheet of empty schedule",
instructions:
"Have student fill out schedule on Google Sheets and print it",
materials: "N/A",
frequency: "Once per week",
target_level: 60,
baseline_level: 0,
attempts_per_trial: 1,
number_of_trials: 16,
metric_name: "",
})
.returning("benchmark_id")
.executeTakeFirstOrThrow();

await db
.insertInto("task")
.values({
benchmark_id: benchmark_student_1_goal_2_id,
assignee_id: firstuser.user_id,
})
.execute();

const { benchmark_id: benchmark_student_2_goal_id } = await db
.insertInto("benchmark")
.values({
goal_id: student_2_goal_id,
status: "In Progress",
description: "Consolidate new class handouts",
setup: "N/A",
instructions:
"Have student write dates and sort handouts by date and class",
materials: "Pen, folders for each class",
frequency: "Tuesdays and Fridays",
target_level: 80,
baseline_level: 0,
attempts_per_trial: 4,
number_of_trials: 16,
metric_name: "",
})
.returning("benchmark_id")
.executeTakeFirstOrThrow();

await db
.insertInto("task")
.values({
benchmark_id: benchmark_student_2_goal_id,
assignee_id: firstuser.user_id,
})
.execute();

logger.info("Database has been seeded with test data.");
};

0 comments on commit c375b83

Please sign in to comment.