-
Notifications
You must be signed in to change notification settings - Fork 0
Hmtv2 20 fetch and show scores #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9ae892f
Built out the frontend and sort of the backend, need to build out the…
Essam-Khawaja 72ea82f
Seed file ready, everything seems to be working, just need to test a …
Essam-Khawaja 3f88621
Added comment to seedScores.ts, and built a small database markdown g…
Essam-Khawaja f09d853
Added requested changes
Essam-Khawaja 1d761b7
Chore: Fixed CI/CD error in ScoreTable.tsx
Essam-Khawaja 520b0b7
Updated the seeding data to now work with roomid, instead of rounds
Essam-Khawaja 74560d9
Fixed pnpm-lock
Essam-Khawaja 7e6f927
Fixed the merge conflicts, removed the readme
Essam-Khawaja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import crypto from "crypto"; | ||
| import { eq } from "drizzle-orm"; | ||
| import { db } from "@/server/db"; | ||
| import { organization, user } from "@/server/db/auth-schema"; | ||
| import { | ||
| hackathonSettings, | ||
| judgingAssignments, | ||
| judgingRoomStaff, | ||
| judgingRooms, | ||
| judgingRounds | ||
| } from "@/server/db/schema"; | ||
| import { criteria, scores } from "@/server/db/scores-schema"; | ||
|
|
||
| async function main() { | ||
| console.log("Starting scoring seed..."); | ||
|
|
||
| try { | ||
| // Create judging round | ||
| const roundId = crypto.randomUUID(); | ||
| await db.insert(judgingRounds).values({ | ||
| id: roundId, | ||
| name: "Round 1", | ||
| startTime: new Date(), | ||
| endTime: new Date(Date.now() + 2 * 60 * 60 * 1000), | ||
| createdAt: new Date(), | ||
| updatedAt: new Date() | ||
| }); | ||
|
|
||
| // Insert criteria | ||
| const criteriaList = [ | ||
| { name: "Innovation", maxScore: 10 }, | ||
| { name: "Technical Complexity", maxScore: 10 }, | ||
| { name: "Design", maxScore: 10 }, | ||
| { name: "Presentation", maxScore: 10 } | ||
| ]; | ||
|
|
||
| const createdCriteria = []; | ||
| for (const c of criteriaList) { | ||
| const id = crypto.randomUUID(); | ||
| await db.insert(criteria).values({ | ||
| id, | ||
| name: c.name, | ||
| maxScore: c.maxScore, | ||
| isSidepot: false | ||
| }); | ||
| createdCriteria.push({ id, ...c }); | ||
| } | ||
|
|
||
| // Get judges and teams | ||
| const judges = await db.select().from(user).where(eq(user.role, "judge")); | ||
| if (judges.length === 0) throw new Error("No judges found"); | ||
|
|
||
| const allTeams = await db.select().from(organization); | ||
| if (allTeams.length === 0) throw new Error("No teams found"); | ||
|
|
||
| // Each judge gets their own room, all teams are assigned to each room | ||
| for (const judge of judges) { | ||
| const roomId = crypto.randomUUID(); | ||
|
|
||
| // Create a room for this judge | ||
| await db.insert(judgingRooms).values({ | ||
| id: roomId, | ||
| roundId, | ||
| roomLink: `https://meet.example.com/room-${roomId}`, | ||
| createdAt: new Date(), | ||
| updatedAt: new Date() | ||
| }); | ||
|
|
||
| // Assign judge as staff for this room | ||
| await db.insert(judgingRoomStaff).values({ | ||
| id: crypto.randomUUID(), | ||
| roomId, | ||
| staffId: judge.id, | ||
| createdAt: new Date() | ||
| }); | ||
|
|
||
| // Assign every team to this room and generate scores | ||
| for (const team of allTeams) { | ||
| const assignmentId = crypto.randomUUID(); | ||
|
|
||
| await db.insert(judgingAssignments).values({ | ||
| id: assignmentId, | ||
| teamId: team.id, | ||
| roomId, | ||
| createdAt: new Date() | ||
| }); | ||
|
|
||
| for (const c of createdCriteria) { | ||
| const randomScore = Math.floor(Math.random() * (c.maxScore + 1)); | ||
| await db.insert(scores).values({ | ||
| id: crypto.randomUUID(), | ||
| assignmentId, | ||
| criteriaId: c.id, | ||
| value: randomScore, | ||
| createdAt: new Date() | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Set active round in hackathon settings | ||
| await db.update(hackathonSettings).set({ currentRoundId: roundId }); | ||
|
|
||
| console.log("Scoring seed completed successfully"); | ||
| process.exit(0); | ||
| } catch (error) { | ||
| console.error("Scoring seed failed:", error); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| "use client"; | ||
|
|
||
| import type { ColDef } from "ag-grid-community"; | ||
| import { | ||
| AllCommunityModule, | ||
| ModuleRegistry, | ||
| themeQuartz | ||
| } from "ag-grid-community"; | ||
| import { AgGridReact } from "ag-grid-react"; | ||
| import { useMemo } from "react"; | ||
| import { api } from "@/trpc/react"; | ||
| import { TABLE_THEME_PARAMS } from "@/types/teamTableConstants"; | ||
| import type { TeamRanking } from "@/types/types"; | ||
|
|
||
| ModuleRegistry.registerModules([AllCommunityModule]); | ||
|
|
||
| export default function ScoreTable() { | ||
| const { data, isLoading } = api.teams.getRankings.useQuery(); | ||
|
|
||
| const theme = themeQuartz.withParams(TABLE_THEME_PARAMS); | ||
|
|
||
| const columnDefs = useMemo<ColDef<TeamRanking>[]>( | ||
| () => [ | ||
| { | ||
| headerName: "Rank", | ||
| width: 100, | ||
| sortable: false, | ||
| valueGetter: (params) => (params.node ? params.node.rowIndex! + 1 : "") | ||
| }, | ||
| { | ||
| headerName: "Team Name", | ||
| field: "name", | ||
| sortable: true, | ||
| filter: true | ||
| }, | ||
| { | ||
| headerName: "Total Score", | ||
| field: "totalScore", | ||
| sort: "desc", // 👈 default descending | ||
| filter: "agNumberColumnFilter", | ||
| sortable: true | ||
| } | ||
| ], | ||
| [] | ||
| ); | ||
|
|
||
| const defaultColDef = useMemo<ColDef<TeamRanking>>( | ||
| () => ({ | ||
| flex: 1, | ||
| resizable: true | ||
| }), | ||
| [] | ||
| ); | ||
|
|
||
| // TODO: remove height and width inline style | ||
| return ( | ||
| <div style={{ height: 600, width: "100%" }}> | ||
| <AgGridReact | ||
| columnDefs={columnDefs} | ||
| defaultColDef={defaultColDef} | ||
| getRowId={({ data }) => data.id} | ||
| loading={isLoading} | ||
| rowData={data ?? []} | ||
| theme={theme} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.