Skip to content

Commit c375b83

Browse files
committed
Add seeds of tasks
1 parent a19c064 commit c375b83

File tree

1 file changed

+142
-4
lines changed

1 file changed

+142
-4
lines changed

src/backend/db/lib/seed.ts

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const seedfile = async (databaseUrl: string) => {
1111
.select("user_id")
1212
.executeTakeFirstOrThrow();
1313

14-
await db
14+
const { student_id: student_1_id } = await db
1515
.insertInto("student")
1616
.values({
1717
first_name: "Edna",
@@ -20,9 +20,10 @@ export const seedfile = async (databaseUrl: string) => {
2020
grade: 1,
2121
assigned_case_manager_id: firstuser.user_id,
2222
})
23-
.execute();
23+
.returning("student_id")
24+
.executeTakeFirstOrThrow();
2425

25-
await db
26+
const { student_id: student_2_id } = await db
2627
.insertInto("student")
2728
.values({
2829
first_name: "Colette",
@@ -31,7 +32,8 @@ export const seedfile = async (databaseUrl: string) => {
3132
grade: 2,
3233
assigned_case_manager_id: firstuser.user_id,
3334
})
34-
.execute();
35+
.returning("student_id")
36+
.executeTakeFirstOrThrow();
3537

3638
await db
3739
.insertInto("student")
@@ -64,5 +66,141 @@ export const seedfile = async (databaseUrl: string) => {
6466
})
6567
.execute();
6668

69+
const { iep_id: student_1_iep_id } = await db
70+
.insertInto("iep")
71+
.values({
72+
case_manager_id: firstuser.user_id,
73+
student_id: student_1_id,
74+
start_date: new Date("2024-11-05"),
75+
end_date: new Date("2028-12-31"),
76+
})
77+
.returning("iep_id")
78+
.executeTakeFirstOrThrow();
79+
80+
const { iep_id: student_2_iep_id } = await db
81+
.insertInto("iep")
82+
.values({
83+
case_manager_id: firstuser.user_id,
84+
student_id: student_2_id,
85+
start_date: new Date("2024-11-04"),
86+
end_date: new Date("2028-12-30"),
87+
})
88+
.returning("iep_id")
89+
.executeTakeFirstOrThrow();
90+
91+
const { goal_id: student_1_goal_1_id } = await db
92+
.insertInto("goal")
93+
.values({
94+
iep_id: student_1_iep_id,
95+
description: "Improve Spanish grade",
96+
category: "other",
97+
})
98+
.returning("goal_id")
99+
.executeTakeFirstOrThrow();
100+
101+
const { goal_id: student_1_goal_2_id } = await db
102+
.insertInto("goal")
103+
.values({
104+
iep_id: student_1_iep_id,
105+
description: "Come to class more punctually",
106+
category: "other",
107+
})
108+
.returning("goal_id")
109+
.executeTakeFirstOrThrow();
110+
111+
const { goal_id: student_2_goal_id } = await db
112+
.insertInto("goal")
113+
.values({
114+
iep_id: student_2_iep_id,
115+
description: "Organize notebook",
116+
category: "other",
117+
})
118+
.returning("goal_id")
119+
.executeTakeFirstOrThrow();
120+
121+
const { benchmark_id: benchmark_student_1_goal_1_id } = await db
122+
.insertInto("benchmark")
123+
.values({
124+
goal_id: student_1_goal_1_id,
125+
status: "In Progress",
126+
description: "Create example sentences from vocab",
127+
setup: "Make Google Sheets from vocab list",
128+
instructions:
129+
"Have student create example sentences for each vocab word in Google Sheets",
130+
materials: "N/A",
131+
frequency: "Once per week",
132+
target_level: 60,
133+
baseline_level: 0,
134+
attempts_per_trial: 1,
135+
number_of_trials: 16,
136+
metric_name: "",
137+
})
138+
.returning("benchmark_id")
139+
.executeTakeFirstOrThrow();
140+
141+
await db
142+
.insertInto("task")
143+
.values({
144+
benchmark_id: benchmark_student_1_goal_1_id,
145+
assignee_id: firstuser.user_id,
146+
})
147+
.execute();
148+
149+
const { benchmark_id: benchmark_student_1_goal_2_id } = await db
150+
.insertInto("benchmark")
151+
.values({
152+
goal_id: student_1_goal_2_id,
153+
status: "In Progress",
154+
description: "Create morning schedule",
155+
setup: "Make Google Sheet of empty schedule",
156+
instructions:
157+
"Have student fill out schedule on Google Sheets and print it",
158+
materials: "N/A",
159+
frequency: "Once per week",
160+
target_level: 60,
161+
baseline_level: 0,
162+
attempts_per_trial: 1,
163+
number_of_trials: 16,
164+
metric_name: "",
165+
})
166+
.returning("benchmark_id")
167+
.executeTakeFirstOrThrow();
168+
169+
await db
170+
.insertInto("task")
171+
.values({
172+
benchmark_id: benchmark_student_1_goal_2_id,
173+
assignee_id: firstuser.user_id,
174+
})
175+
.execute();
176+
177+
const { benchmark_id: benchmark_student_2_goal_id } = await db
178+
.insertInto("benchmark")
179+
.values({
180+
goal_id: student_2_goal_id,
181+
status: "In Progress",
182+
description: "Consolidate new class handouts",
183+
setup: "N/A",
184+
instructions:
185+
"Have student write dates and sort handouts by date and class",
186+
materials: "Pen, folders for each class",
187+
frequency: "Tuesdays and Fridays",
188+
target_level: 80,
189+
baseline_level: 0,
190+
attempts_per_trial: 4,
191+
number_of_trials: 16,
192+
metric_name: "",
193+
})
194+
.returning("benchmark_id")
195+
.executeTakeFirstOrThrow();
196+
197+
await db
198+
.insertInto("task")
199+
.values({
200+
benchmark_id: benchmark_student_2_goal_id,
201+
assignee_id: firstuser.user_id,
202+
})
203+
.execute();
204+
67205
logger.info("Database has been seeded with test data.");
68206
};

0 commit comments

Comments
 (0)