website refactor

This commit is contained in:
2026-01-21 12:55:22 +01:00
parent a6e93acb37
commit 7075765d98
14 changed files with 489 additions and 19 deletions

View File

@@ -38,7 +38,9 @@ export class GetLeagueFullConfigUseCase {
const { leagueId } = input;
try {
console.log('Getting league with ID:', leagueId);
const league = await this.leagueRepository.findById(leagueId);
console.log('League result:', league);
if (!league) {
return Result.err({
code: 'LEAGUE_NOT_FOUND',
@@ -46,20 +48,40 @@ export class GetLeagueFullConfigUseCase {
});
}
console.log('League settings:', JSON.stringify(league.settings, null, 2));
const seasons = await this.seasonRepository.findByLeagueId(leagueId);
console.log('Seasons found:', seasons?.length);
const activeSeason =
seasons && seasons.length > 0
? seasons.find((s) => s.status.isActive()) ?? seasons[0]
: undefined;
console.log('Active season:', activeSeason?.id);
const scoringConfig = await (async () => {
if (!activeSeason) return null;
return (await this.leagueScoringConfigRepository.findBySeasonId(activeSeason.id)) ?? null;
console.log('Getting scoring config for season:', activeSeason.id);
try {
const result = await this.leagueScoringConfigRepository.findBySeasonId(activeSeason.id);
console.log('Scoring config result:', result);
return result ?? null;
} catch (error) {
console.error('Error getting scoring config for season:', activeSeason.id, error);
throw error;
}
})();
const game = await (async () => {
if (!activeSeason || !activeSeason.gameId) return null;
return (await this.gameRepository.findById(activeSeason.gameId)) ?? null;
console.log('Getting game for game ID:', activeSeason.gameId);
try {
const result = await this.gameRepository.findById(activeSeason.gameId);
console.log('Game result:', result);
return result ?? null;
} catch (error) {
console.error('Error getting game for game ID:', activeSeason.gameId, error);
throw error;
}
})();
const config: LeagueFullConfig = {
@@ -80,6 +102,9 @@ export class GetLeagueFullConfigUseCase {
? error.message
: 'Failed to load league full configuration';
console.error('GetLeagueFullConfigUseCase error:', error);
console.error('Error stack:', error instanceof Error ? error.stack : 'No stack trace');
return Result.err({
code: 'REPOSITORY_ERROR',
details: { message },