aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/db
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-07 23:22:07 +0900
committernsfisis <nsfisis@gmail.com>2024-08-08 04:02:37 +0900
commit47d81ffbd3e4fe178d2935325e312cef77276250 (patch)
tree341f7aaa3429dbecc60cbfad0a84e6846152814e /backend/db
parent14f48b4e4f7463e0972c2a5b39e94ee674ec93ba (diff)
downloadphperkaigi-2025-albatross-47d81ffbd3e4fe178d2935325e312cef77276250.tar.gz
phperkaigi-2025-albatross-47d81ffbd3e4fe178d2935325e312cef77276250.tar.zst
phperkaigi-2025-albatross-47d81ffbd3e4fe178d2935325e312cef77276250.zip
feat(backend): create submission_results table
Diffstat (limited to 'backend/db')
-rw-r--r--backend/db/models.go9
-rw-r--r--backend/db/query.sql.go22
2 files changed, 31 insertions, 0 deletions
diff --git a/backend/db/models.go b/backend/db/models.go
index 49e4b52..d4cf98b 100644
--- a/backend/db/models.go
+++ b/backend/db/models.go
@@ -39,6 +39,15 @@ type Submission struct {
CreatedAt pgtype.Timestamp
}
+type SubmissionResult struct {
+ SubmissionResultID int32
+ SubmissionID int32
+ Status string
+ Stdout string
+ Stderr string
+ CreatedAt pgtype.Timestamp
+}
+
type Testcase struct {
TestcaseID int32
ProblemID int32
diff --git a/backend/db/query.sql.go b/backend/db/query.sql.go
index 6c78267..cfb97fd 100644
--- a/backend/db/query.sql.go
+++ b/backend/db/query.sql.go
@@ -36,6 +36,28 @@ func (q *Queries) CreateSubmission(ctx context.Context, arg CreateSubmissionPara
return submission_id, err
}
+const createSubmissionResult = `-- name: CreateSubmissionResult :exec
+INSERT INTO submission_results (submission_id, status, stdout, stderr)
+VALUES ($1, $2, $3, $4)
+`
+
+type CreateSubmissionResultParams struct {
+ SubmissionID int32
+ Status string
+ Stdout string
+ Stderr string
+}
+
+func (q *Queries) CreateSubmissionResult(ctx context.Context, arg CreateSubmissionResultParams) error {
+ _, err := q.db.Exec(ctx, createSubmissionResult,
+ arg.SubmissionID,
+ arg.Status,
+ arg.Stdout,
+ arg.Stderr,
+ )
+ return err
+}
+
const createTestcaseResult = `-- name: CreateTestcaseResult :exec
INSERT INTO testcase_results (submission_id, testcase_id, status, stdout, stderr)
VALUES ($1, $2, $3, $4, $5)