Skip to content

Commit 940b028

Browse files
committed
Simplify contest schema
1 parent 5a54f14 commit 940b028

File tree

7 files changed

+1353
-33
lines changed

7 files changed

+1353
-33
lines changed

app/[orgId]/contests/page.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ const fields: Field[] = [
3939
placeholder: "Comma-separated problem IDs",
4040
},
4141
{ name: "rules", label: "Rules", type: "textarea" },
42-
{
43-
name: "registrationStartTime",
44-
label: "Registration Start",
45-
type: "datetime",
46-
},
47-
{ name: "registrationEndTime", label: "Registration End", type: "datetime" },
4842
];
4943

5044
const contestSchema = z.object({
@@ -56,8 +50,6 @@ const contestSchema = z.object({
5650
endTime: z.string(),
5751
problems: z.string(),
5852
rules: z.string().default(""),
59-
registrationStartTime: z.string().default(new Date().toISOString()),
60-
registrationEndTime: z.string().default(new Date().toISOString()),
6153
}) as z.ZodType<Contest, z.ZodTypeDef, Contest>;
6254

6355
const injectProblemsCount = (contests: Contest[]) => {

app/api/orgs/[orgId]/contests/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ export async function POST(
2727
return NextResponse.json({ error: error.message }, { status: 409 });
2828
}
2929
}
30+
console.error(error);
3031
return NextResponse.json(
31-
{ error: "Failed to create contest" },
32+
{ error: `Failed to create contest: ${error}` },
3233
{ status: 500 },
3334
);
3435
}

db/schema.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,8 @@ export const contests = pgTable(
117117
description: text("description").notNull(), // Use Markdown for description
118118
rules: text("rules").notNull(),
119119

120-
// remove
121-
registrationStartTime: timestamp("registration_start_time").notNull(),
122-
registrationEndTime: timestamp("registration_end_time").notNull(),
123-
124120
startTime: timestamp("start_time").notNull(),
125121
endTime: timestamp("end_time").notNull(),
126-
127-
// remove
128-
allowList: text("allow_list").array().notNull(),
129-
disallowList: text("disallow_list").array().notNull(),
130122
},
131123
(table) => {
132124
return {

lib/validations.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,8 @@ export const createContestSchema = z
129129
"1. Individual participation only\n2. 3-hour duration\n3. Standard library allowed",
130130
description: "Contest rules and guidelines",
131131
}),
132-
registrationStartTime: TimestampSchema,
133-
registrationEndTime: TimestampSchema,
134132
startTime: TimestampSchema,
135133
endTime: TimestampSchema,
136-
allowList: z
137-
.array(z.string().email())
138-
.default([])
139-
.openapi({
140-
141-
description: "List of emails allowed to participate",
142-
}),
143-
disallowList: z
144-
.array(z.string().email())
145-
.default([])
146-
.openapi({
147-
example: ["[email protected]"],
148-
description: "List of emails not allowed to participate",
149-
}),
150134
problems: z.string().optional().openapi({
151135
example: "A,B,C,D",
152136
description: "Contest problems configuration",

migrations/0004_aberrant_namor.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE "contests" DROP COLUMN "registration_start_time";--> statement-breakpoint
2+
ALTER TABLE "contests" DROP COLUMN "registration_end_time";--> statement-breakpoint
3+
ALTER TABLE "contests" DROP COLUMN "allow_list";--> statement-breakpoint
4+
ALTER TABLE "contests" DROP COLUMN "disallow_list";

0 commit comments

Comments
 (0)