feat(practice): run practice jobs on the code runner with one stored result per run

This commit is contained in:
shira committed 2026-10-11 19:31:08 +03:00
1 parent 9385b2ddd4
commit 9344228e84
17 files changed
+1010 -35

No files matched your search

@@ -292,11 +292,18 @@ func createPractice(
if err != nil {
t.Fatalf("generate practice ID: %v", err)
}
// A submission is stamped with the database time, so the practice is
// created with it too: a database clock slightly behind the test host
// would otherwise put the first submission before its practice.
var createdAt time.Time
if err := pool.QueryRow(ctx, `SELECT clock_timestamp()`).Scan(&createdAt); err != nil {
t.Fatalf("read database time: %v", err)
}
transactor := postgresadapter.NewTransactor(pool)
err = transactor.WithinTransaction(ctx, func(ctx context.Context, unit outbound.UnitOfWork) error {
return unit.AssessmentPractices().Create(ctx, domain.AssessmentPractice{
ID: id, AttemptID: domain.AssessmentAttemptID(attemptID), UserID: userID, Kind: kind, Task: practiceTestTask(),
Status: domain.AssessmentPracticeNotStarted, CreatedAt: time.Now().UTC().Truncate(time.Microsecond),
Status: domain.AssessmentPracticeNotStarted, CreatedAt: createdAt.UTC().Truncate(time.Microsecond),
})
})
if err != nil {