Skip to content

Commit

Permalink
Restore getBenchmarkAndTrialData to also grab task, at least temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
canjalal committed Jan 10, 2025
1 parent 5cdd9eb commit 628a8e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/backend/routers/iep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,18 +393,21 @@ export const iep = router({
getBenchmarkAndTrialData: hasPara
.input(
z.object({
benchmark_id: z.string(),
task_id: z.string(),
})
)
.query(async (req) => {
const { benchmark_id } = req.input;
const { task_id } = req.input;

const result = await req.ctx.db
.selectFrom("benchmark")
.innerJoin("task", "benchmark.benchmark_id", "task.benchmark_id")
.innerJoin("goal", "benchmark.goal_id", "goal.goal_id")
.innerJoin("iep", "goal.iep_id", "iep.iep_id")
.innerJoin("student", "iep.student_id", "student.student_id")
.where("task.task_id", "=", task_id)
.select((eb) => [
"task.task_id",
"benchmark.benchmark_id",
"student.first_name",
"student.last_name",
Expand All @@ -414,6 +417,9 @@ export const iep = router({
"benchmark.frequency",
"benchmark.number_of_trials",
"benchmark.benchmark_id",
"task.due_date",
"task.seen",
"task.trial_count",
jsonArrayFrom(
eb
.selectFrom("trial_data")
Expand All @@ -440,10 +446,14 @@ export const iep = router({
"=",
"benchmark.benchmark_id"
)
.whereRef(
"trial_data.created_by_user_id",
"=",
"task.assignee_id"
)
.orderBy("trial_data.created_at")
).as("trials"),
])
.where("benchmark.benchmark_id", "=", benchmark_id)
.executeTakeFirstOrThrow();

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/benchmarks/[benchmark_id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const BenchmarkPage = () => {
isError,
} = trpc.iep.getBenchmarkAndTrialData.useQuery(
{
task_id: benchmark_id as string,
task_id: benchmark_id as string, // how does this line make sense?
},
{
enabled: Boolean(benchmark_id),
Expand Down

0 comments on commit 628a8e2

Please sign in to comment.