inmemory to postgres
This commit is contained in:
@@ -22,6 +22,8 @@ import type { IPenaltyRepository } from '@core/racing/domain/repositories/IPenal
|
||||
import type { IFeedRepository } from '@core/social/domain/repositories/IFeedRepository';
|
||||
import type { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';
|
||||
import { createRacingSeed } from './racing/RacingSeed';
|
||||
import { getApiPersistence } from '../../apps/api/src/env';
|
||||
import { seedId } from './racing/SeedIdHelper';
|
||||
|
||||
export type RacingSeedDependencies = {
|
||||
driverRepository: IDriverRepository;
|
||||
@@ -60,7 +62,8 @@ export class SeedRacingData {
|
||||
return;
|
||||
}
|
||||
|
||||
const seed = createRacingSeed();
|
||||
const persistence = getApiPersistence();
|
||||
const seed = createRacingSeed({ persistence });
|
||||
|
||||
let sponsorshipRequestsSeededViaRepo = false;
|
||||
const seedableSponsorshipRequests = this.seedDeps
|
||||
@@ -97,7 +100,7 @@ export class SeedRacingData {
|
||||
|
||||
const activeSeasons = seed.seasons.filter((season) => season.status.isActive());
|
||||
for (const season of activeSeasons) {
|
||||
const presetId = this.selectScoringPresetIdForSeason(season);
|
||||
const presetId = this.selectScoringPresetIdForSeason(season, persistence);
|
||||
const preset = getLeagueScoringPresetById(presetId);
|
||||
|
||||
if (!preset) {
|
||||
@@ -276,7 +279,7 @@ export class SeedRacingData {
|
||||
const existing = await this.seedDeps.leagueScoringConfigRepository.findBySeasonId(season.id);
|
||||
if (existing) continue;
|
||||
|
||||
const presetId = this.selectScoringPresetIdForSeason(season);
|
||||
const presetId = this.selectScoringPresetIdForSeason(season, 'postgres');
|
||||
const preset = getLeagueScoringPresetById(presetId);
|
||||
|
||||
if (!preset) {
|
||||
@@ -297,13 +300,16 @@ export class SeedRacingData {
|
||||
}
|
||||
}
|
||||
|
||||
private selectScoringPresetIdForSeason(season: Season): string {
|
||||
if (season.leagueId === 'league-5' && season.status.isActive()) {
|
||||
private selectScoringPresetIdForSeason(season: Season, persistence: 'postgres' | 'inmemory'): string {
|
||||
const expectedLeagueId = seedId('league-5', persistence);
|
||||
const expectedSeasonId = seedId('season-1-b', persistence);
|
||||
|
||||
if (season.leagueId === expectedLeagueId && season.status.isActive()) {
|
||||
return 'sprint-main-driver';
|
||||
}
|
||||
|
||||
if (season.leagueId === 'league-3') {
|
||||
return season.id.endsWith('-b') ? 'sprint-main-team' : 'club-default-nations';
|
||||
if (season.leagueId === seedId('league-3', persistence)) {
|
||||
return season.id === expectedSeasonId ? 'sprint-main-team' : 'club-default-nations';
|
||||
}
|
||||
|
||||
const match = /^league-(\d+)$/.exec(season.leagueId);
|
||||
|
||||
Reference in New Issue
Block a user