Skip to content

Commit

Permalink
Fix BenchmarkAssignmentModal, add comments on next steps
Browse files Browse the repository at this point in the history
  • Loading branch information
francisli committed Jan 24, 2025
1 parent 34251a2 commit 596d189
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/backend/routers/iep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ export const iep = router({
.mutation(async (req) => {
const { benchmark_id, para_ids } = req.input;

// TODO: instead of throwing an error if a task already exists,
// just add/remove existing tasks as needed.

const existingTasks = await req.ctx.db
.selectFrom("task")
.where("benchmark_id", "=", benchmark_id)
Expand Down
22 changes: 13 additions & 9 deletions src/components/benchmarks/BenchmarkAssignmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const BenchmarkAssignmentModal = (
const [errorMessage, setErrorMessage] = useState<string>("");

const assignTaskToPara = trpc.iep.assignTaskToParas.useMutation();
const updateBenchmark = trpc.iep.updateBenchmark.useMutation();

const handleParaToggle = (paraId: string) => () => {
setErrorMessage("");
Expand Down Expand Up @@ -95,18 +96,21 @@ export const BenchmarkAssignmentModal = (
} else {
// Reached end, save
try {
// maybe invoke these two in parallel?
await assignTaskToPara.mutateAsync({
benchmark_id: props.benchmark_id,
para_ids: selectedParaIds,
// this should be written to benchmarks:
// due_date:
// assignmentDuration.type === "until_date"
// ? assignmentDuration.date
// : undefined,
// trial_count:
// assignmentDuration.type === "minimum_number_of_collections"
// ? assignmentDuration.minimumNumberOfCollections
// : undefined,
});
await updateBenchmark.mutateAsync({
benchmark_id: props.benchmark_id,
due_date:
assignmentDuration.type === "until_date"
? assignmentDuration.date
: undefined,
trial_count:
assignmentDuration.type === "minimum_number_of_collections"
? assignmentDuration.minimumNumberOfCollections
: undefined,
});
handleClose();
} catch (err) {
Expand Down

0 comments on commit 596d189

Please sign in to comment.