From 144da5d158e89f5affcfe3d8adfb3042688bd9c5 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:32:13 +0200 Subject: [PATCH] Tournament groups->SE, underground bracket etc. (#1628) * Renders groups * Bracket data refactoring * Starting bracket working (first bracket only) * TODOs + crash fix * Source bracket logic initial * Bracket progression (DE underground bracket) * Preview working for second bracket * Bracket nav initial * Check-in to bracket feature * Start Underground bracket * Team/teams pages tweaks to support underground bracket * Underground bracket finalization progress * Tournament class * id -> userId + more useOutletContext removed * Bracket loader refactored out * Migrate admin to useTournament * Bracket.settings * Slim tournament loader * Fix useEffect infinite loop * Adjust waiting for teams text * Refactor old tournament DB call from to admin * Admin action: check in/out from specific bracket * Standings work * Back button from match page -> correct bracket * Standings logic for DE grand finals * Standings + finalize bracket * Dev log * Unit tests utils etc. * Adjust TODOs * Fix round robin issues * Add RR tests * Round robin standings initial * Wins against tied + points tiebreaker progress * Fix losing state when switching between tabs * Add check-in indications to seeding page * Link to user page on seed tool * Submit points * Total points from bracket manager * findById gonezino * Ahead of time check-in * Couple todos * Reopen logic refactor * Tournament format settings * RR->SE placements, skipping underground bracket * Fix tournament team page round names * More teams to UG bracket if first round of DE only byes * Fix graphics bug * Fixes * Fix some E2E tests * Fix E2E tests --- app/components/Label.tsx | 4 +- app/db/seed/index.ts | 137 +++- app/db/tables.ts | 25 +- app/db/types.ts | 3 - app/features/api-private/routes/seed.tsx | 2 +- .../calendar/CalendarRepository.server.ts | 33 +- .../calendar/calendar-utils.server.ts | 80 ++ app/features/calendar/calendar-utils.ts | 10 + app/features/calendar/routes/calendar.new.tsx | 178 ++++- .../tournament-bracket/brackets-viewer.css | 30 +- .../components/ScoreReporter.tsx | 109 +-- .../components/ScoreReporterRosters.tsx | 58 +- .../components/TeamRosterInputs.tsx | 211 ++++-- .../tournament-bracket/core/Bracket.ts | 707 ++++++++++++++++++ .../core/Tournament.server.ts | 53 ++ .../tournament-bracket/core/Tournament.ts | 611 +++++++++++++++ .../tournament-bracket/core/bestOf.server.ts | 18 +- .../tournament-bracket/core/bestOf.test.ts | 8 +- .../core/brackets-manager/crud-db.server.ts | 34 +- .../core/summarizer.server.ts | 19 +- .../core/summarizer.test.ts | 43 +- .../tournament-bracket/core/tests/mocks.ts | 638 ++++++++++++++++ .../core/tests/round-robin.test.ts | 289 +++++++ .../core/tests/test-utils.ts | 126 ++++ .../core/tests/underground-bracket.ts | 1 + app/features/tournament-bracket/index.ts | 5 +- ...r.ts => findAllMatchesByStageId.server.ts} | 8 +- .../queries/findResultsByMatchId.server.ts | 5 + .../insertTournamentMatchGameResult.server.ts | 7 +- .../routes/to.$id.brackets.tsx | 682 +++++++---------- .../routes/to.$id.matches.$mid.tsx | 189 ++--- .../tournament-bracket-schemas.server.ts | 32 +- .../tournament-bracket-utils.ts | 114 +-- .../tournament-bracket/tournament-bracket.css | 7 + .../tournament-subs/routes/to.$id.subs.tsx | 64 +- .../tournament/TournamentRepository.server.ts | 248 +++++- .../tournament/components/TeamWithRoster.tsx | 10 +- app/features/tournament/core/sets.server.ts | 58 +- app/features/tournament/index.ts | 11 +- .../queries/findByIdentifier.server.ts | 15 +- ....ts => findRoundsByTournamentId.server.ts} | 7 +- .../queries/findTeamsByTournamentId.server.ts | 2 +- .../queries/setHistoryByTeamId.server.ts | 2 + .../tournament/routes/to.$id.admin.tsx | 294 ++++---- .../tournament/routes/to.$id.index.tsx | 2 +- .../tournament/routes/to.$id.join.tsx | 29 +- .../tournament/routes/to.$id.maps.tsx | 64 +- .../tournament/routes/to.$id.register.tsx | 214 +++--- .../tournament/routes/to.$id.seeds.tsx | 91 +-- .../tournament/routes/to.$id.streams.tsx | 31 +- .../tournament/routes/to.$id.teams.$tid.tsx | 146 ++-- .../tournament/routes/to.$id.teams.tsx | 9 +- app/features/tournament/routes/to.$id.tsx | 148 ++-- .../tournament/tournament-constants.ts | 12 + app/features/tournament/tournament-hooks.ts | 17 +- .../tournament/tournament-schemas.server.ts | 3 + app/features/tournament/tournament-utils.ts | 86 +-- .../user-page/components/UserResultsTable.tsx | 6 +- app/modules/brackets-manager/base/updater.ts | 26 +- app/modules/brackets-manager/helpers.ts | 6 +- .../test/double-elimination.test.ts | 100 --- .../test/single-elimination.test.ts | 44 -- .../brackets-manager/test/update.test.ts | 161 ---- app/modules/brackets-model/other.ts | 6 +- app/permissions.ts | 45 +- app/styles/layout.css | 2 +- app/styles/utils.css | 8 + app/styles/vars.css | 1 + app/utils/arrays.ts | 9 +- app/utils/remix.ts | 11 + app/utils/urls.ts | 12 +- db-test.sqlite3 | Bin 745472 -> 753664 bytes e2e/shared.ts | 2 +- e2e/tournament-bracket.spec.ts | 46 +- e2e/tournament-staff.spec.ts | 2 +- e2e/tournament.spec.ts | 27 +- migrations/046-tournament-progression.js | 18 + public/locales/en/tournament.json | 9 +- public/locales/fr/tournament.json | 4 - public/locales/he/tournament.json | 4 - public/locales/ja/tournament.json | 4 - public/locales/pt-BR/tournament.json | 4 - public/locales/zh/tournament.json | 4 - 83 files changed, 4584 insertions(+), 2016 deletions(-) create mode 100644 app/features/tournament-bracket/core/Bracket.ts create mode 100644 app/features/tournament-bracket/core/Tournament.server.ts create mode 100644 app/features/tournament-bracket/core/Tournament.ts create mode 100644 app/features/tournament-bracket/core/tests/mocks.ts create mode 100644 app/features/tournament-bracket/core/tests/round-robin.test.ts create mode 100644 app/features/tournament-bracket/core/tests/test-utils.ts create mode 100644 app/features/tournament-bracket/core/tests/underground-bracket.ts rename app/features/tournament-bracket/queries/{findAllMatchesByTournamentId.server.ts => findAllMatchesByStageId.server.ts} (68%) rename app/features/tournament/queries/{findRoundNumbersByTournamentId.server.ts => findRoundsByTournamentId.server.ts} (71%) create mode 100644 migrations/046-tournament-progression.js diff --git a/app/components/Label.tsx b/app/components/Label.tsx index 08e349d28..f5c430a49 100644 --- a/app/components/Label.tsx +++ b/app/components/Label.tsx @@ -14,6 +14,7 @@ type LabelProps = Pick< required?: boolean; className?: string; labelClassName?: string; + spaced?: boolean; }; export function Label({ @@ -23,9 +24,10 @@ export function Label({ htmlFor, className, labelClassName, + spaced = true, }: LabelProps) { return ( -