From 694f4e0ca891cc1e675e13fc874aacabbebfe81b Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:59:22 +0200 Subject: [PATCH] Improve seed to not contain impossible state --- app/db/seed/index.ts | 114 +++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 68 deletions(-) diff --git a/app/db/seed/index.ts b/app/db/seed/index.ts index beb13fb74..8a5e6838d 100644 --- a/app/db/seed/index.ts +++ b/app/db/seed/index.ts @@ -40,7 +40,6 @@ import * as SQMatchRepository from "~/features/sendouq-match/SQMatchRepository.s import { BANNED_MAPS } from "~/features/sendouq-settings/banned-maps"; import * as QSettingsRepository from "~/features/sendouq-settings/QSettingsRepository.server"; import { AMOUNT_OF_MAPS_IN_POOL_PER_MODE } from "~/features/sendouq-settings/q-settings-constants"; -import { joinTeam } from "~/features/tournament/queries/joinLeaveTeam.server"; import { clearAllTournamentDataCache } from "~/features/tournament-bracket/core/Tournament.server"; import * as TournamentLFGRepository from "~/features/tournament-lfg/TournamentLFGRepository.server"; import * as TournamentOrganizationRepository from "~/features/tournament-organization/TournamentOrganizationRepository.server"; @@ -1636,16 +1635,14 @@ function tournamentSubs() { async function tournamentLfgGroups() { const availableUsers = userIdsInAscendingOrderById().slice(300); - const tournaments = [ - { tournamentId: 1, teamId: 1 }, - { tournamentId: 2, teamId: 116 }, - { tournamentId: 3, teamId: 201 }, - ]; + const MAX_GROUP_SIZE = 6; + + const tournaments = [1, 2, 3]; let userIndex = 0; - for (const { tournamentId, teamId } of tournaments) { - const users = availableUsers.slice(userIndex, userIndex + 12); - userIndex += 12; + for (const tournamentId of tournaments) { + const users = availableUsers.slice(userIndex, userIndex + 8); + userIndex += 8; // Group 1: solo placeholder, has note, isStayAsSub=1 const { id: team1Id } = await TournamentLFGRepository.createPlaceholderTeam( @@ -1660,81 +1657,62 @@ async function tournamentLfgGroups() { value: "Looking for a team, can play any role", }); - // Group 2: duo placeholder + // Group 2: solo placeholder const { id: team2Id } = await TournamentLFGRepository.createPlaceholderTeam( { tournamentId, userId: users[1], }, ); - joinTeam({ - newTeamId: team2Id, - userId: users[2], - inGameName: null, - tournamentId, - }); - // Group 3: trio placeholder + // Group 3: solo placeholder const { id: team3Id } = await TournamentLFGRepository.createPlaceholderTeam( + { + tournamentId, + userId: users[2], + }, + ); + + // Group 4: solo placeholder + const { id: team4Id } = await TournamentLFGRepository.createPlaceholderTeam( { tournamentId, userId: users[3], }, ); - joinTeam({ - newTeamId: team3Id, - userId: users[4], - inGameName: null, - tournamentId, - }); - joinTeam({ - newTeamId: team3Id, - userId: users[5], - inGameName: null, - tournamentId, + + // Group 5: 2-member group (merged from two placeholders) + const { id: mergeTarget1 } = + await TournamentLFGRepository.createPlaceholderTeam({ + tournamentId, + userId: users[4], + }); + const { id: mergeSource1 } = + await TournamentLFGRepository.createPlaceholderTeam({ + tournamentId, + userId: users[5], + }); + await TournamentLFGRepository.mergeTeams({ + survivingTeamId: mergeTarget1, + otherTeamId: mergeSource1, + maxGroupSize: MAX_GROUP_SIZE, }); - // Group 4: full (4 members) placeholder - const { id: team4Id } = await TournamentLFGRepository.createPlaceholderTeam( - { + // Group 6: 2-member group (merged from two placeholders) + const { id: mergeTarget2 } = + await TournamentLFGRepository.createPlaceholderTeam({ tournamentId, userId: users[6], - }, - ); - joinTeam({ - newTeamId: team4Id, - userId: users[7], - inGameName: null, - tournamentId, - }); - joinTeam({ - newTeamId: team4Id, - userId: users[8], - inGameName: null, - tournamentId, - }); - joinTeam({ - newTeamId: team4Id, - userId: users[9], - inGameName: null, - tournamentId, - }); - - // Group 5: solo placeholder - const { id: team5Id } = await TournamentLFGRepository.createPlaceholderTeam( - { + }); + const { id: mergeSource2 } = + await TournamentLFGRepository.createPlaceholderTeam({ tournamentId, - userId: users[10], - }, - ); - - // Group 6: existing team set to looking - await TournamentLFGRepository.startLooking(teamId); - joinTeam({ - newTeamId: teamId, - userId: users[11], - inGameName: null, - tournamentId, + userId: users[7], + }); + await TournamentLFGRepository.mergeTeams({ + survivingTeamId: mergeTarget2, + otherTeamId: mergeSource2, + maxGroupSize: MAX_GROUP_SIZE, }); // Team 1 -> Team 2 (one-way like) @@ -1747,10 +1725,10 @@ async function tournamentLfgGroups() { likerTeamId: team2Id, targetTeamId: team1Id, }); - // Team 3 -> Team 5 (one-way like) + // Team 3 -> Team 4 (one-way like) await TournamentLFGRepository.addLike({ likerTeamId: team3Id, - targetTeamId: team5Id, + targetTeamId: team4Id, }); } }