Skip to content

Commit e319736

Browse files
committed
add hall of fame
1 parent 002a23e commit e319736

7 files changed

Lines changed: 32 additions & 5 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- RedefineTables
2+
PRAGMA defer_foreign_keys=ON;
3+
PRAGMA foreign_keys=OFF;
4+
CREATE TABLE "new_Team" (
5+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
6+
"name" TEXT NOT NULL,
7+
"hallOfFame" BOOLEAN NOT NULL DEFAULT false,
8+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
9+
"courseOfferingId" INTEGER NOT NULL,
10+
CONSTRAINT "Team_courseOfferingId_fkey" FOREIGN KEY ("courseOfferingId") REFERENCES "CourseOffering" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
11+
);
12+
INSERT INTO "new_Team" ("courseOfferingId", "createdAt", "id", "name") SELECT "courseOfferingId", "createdAt", "id", "name" FROM "Team";
13+
DROP TABLE "Team";
14+
ALTER TABLE "new_Team" RENAME TO "Team";
15+
CREATE UNIQUE INDEX "Team_name_key" ON "Team"("name");
16+
PRAGMA foreign_keys=ON;
17+
PRAGMA defer_foreign_keys=OFF;

prisma/schema.prisma

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ model CourseOffering {
6666
}
6767

6868
model Team {
69-
id Int @id @default(autoincrement())
70-
name String @unique
71-
createdAt DateTime @default(now())
69+
id Int @id @default(autoincrement())
70+
name String @unique
71+
hallOfFame Boolean @default(false)
72+
createdAt DateTime @default(now())
7273
7374
CourseOffering CourseOffering @relation(fields: [courseOfferingId], references: [id])
7475
courseOfferingId Int

src/admin/adminController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export const getAllProjects = async (_req: Request, res: Response) => {
151151
team: {
152152
id: number;
153153
name: string;
154+
hallOfFame: boolean;
154155
courseOffering: {
155156
id: number;
156157
course: {
@@ -196,6 +197,7 @@ export const getAllProjects = async (_req: Request, res: Response) => {
196197
team: {
197198
id: project.team.id,
198199
name: project.team.name,
200+
hallOfFame: project.team.hallOfFame,
199201
courseOffering: {
200202
id: project.team.CourseOffering.id,
201203
course: {

src/projects/projectService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ export const getTeamProjects = async (teamId: number) => {
384384
select: {
385385
id: true,
386386
name: true,
387+
hallOfFame: true,
387388
},
388389
},
389390
deployedBy: {
@@ -410,6 +411,7 @@ export const getProjectById = async (projectId: number) => {
410411
select: {
411412
id: true,
412413
name: true,
414+
hallOfFame: true,
413415
},
414416
},
415417
deployedBy: {
@@ -588,6 +590,7 @@ export const getAllProjects = async () => {
588590
select: {
589591
id: true,
590592
name: true,
593+
hallOfFame: true,
591594
},
592595
},
593596
deployedBy: {

src/teams/team.schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const updateTeamSchema = z.object({
1111
body: z.object({
1212
name: z.string().min(1).max(100).optional(),
1313
memberEmails: z.array(z.string().email()).optional(),
14+
hallOfFame: z.boolean().optional(),
1415
}),
1516
});
1617

src/teams/teamController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const createTeam = async (req: Request, res: Response) => {
191191
export const updateTeam = async (req: Request, res: Response) => {
192192
const { userId, isAdmin } = req.user!;
193193
const teamId = parseInt(req.params.teamId, 10);
194-
const { name, memberEmails } = req.body;
194+
const { name, memberEmails, hallOfFame } = req.body;
195195

196196
const team = await prisma.team.findUnique({
197197
where: { id: teamId },
@@ -213,7 +213,7 @@ export const updateTeam = async (req: Request, res: Response) => {
213213
}
214214

215215
// Update team using service (handles name validation, user creation, enrollment)
216-
const updatedTeam = await updateTeamWithMembers(teamId, name, memberEmails);
216+
const updatedTeam = await updateTeamWithMembers(teamId, name, memberEmails, hallOfFame);
217217

218218
return res.json(updatedTeam);
219219
};

src/teams/teamService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,14 @@ export const createTeamWithMembers = async (
132132
* @param teamId - The ID of the team to update
133133
* @param name - Optional new team name
134134
* @param memberEmails - Optional new list of member emails (replaces existing members)
135+
* @param hallOfFame - Optional hall of fame status
135136
* @returns The updated team
136137
*/
137138
export const updateTeamWithMembers = async (
138139
teamId: number,
139140
name?: string,
140141
memberEmails?: string[],
142+
hallOfFame?: boolean,
141143
) => {
142144
const team = await prisma.team.findUnique({
143145
where: { id: teamId },
@@ -168,6 +170,7 @@ export const updateTeamWithMembers = async (
168170
where: { id: teamId },
169171
data: {
170172
...(name && { name }),
173+
...(hallOfFame !== undefined && { hallOfFame }),
171174
...(memberUserIds && {
172175
members: {
173176
deleteMany: {},

0 commit comments

Comments
 (0)