more seeds
This commit is contained in:
@@ -8,6 +8,14 @@ import type { ILeagueMembershipRepository } from '@core/racing/domain/repositori
|
||||
import type { IRaceRegistrationRepository } from '@core/racing/domain/repositories/IRaceRegistrationRepository';
|
||||
import type { ITeamRepository } from '@core/racing/domain/repositories/ITeamRepository';
|
||||
import type { ITeamMembershipRepository } from '@core/racing/domain/repositories/ITeamMembershipRepository';
|
||||
import type { ISponsorRepository } from '@core/racing/domain/repositories/ISponsorRepository';
|
||||
import type { ISeasonRepository } from '@core/racing/domain/repositories/ISeasonRepository';
|
||||
import type { ISeasonSponsorshipRepository } from '@core/racing/domain/repositories/ISeasonSponsorshipRepository';
|
||||
import type { ISponsorshipRequestRepository } from '@core/racing/domain/repositories/ISponsorshipRequestRepository';
|
||||
import type { ILeagueWalletRepository } from '@core/racing/domain/repositories/ILeagueWalletRepository';
|
||||
import type { ITransactionRepository } from '@core/racing/domain/repositories/ITransactionRepository';
|
||||
import type { IProtestRepository } from '@core/racing/domain/repositories/IProtestRepository';
|
||||
import type { IPenaltyRepository } from '@core/racing/domain/repositories/IPenaltyRepository';
|
||||
import type { IFeedRepository } from '@core/social/domain/repositories/IFeedRepository';
|
||||
import type { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';
|
||||
import { createRacingSeed } from './racing/RacingSeed';
|
||||
@@ -15,6 +23,13 @@ import { createRacingSeed } from './racing/RacingSeed';
|
||||
export type RacingSeedDependencies = {
|
||||
driverRepository: IDriverRepository;
|
||||
leagueRepository: ILeagueRepository;
|
||||
seasonRepository: ISeasonRepository;
|
||||
seasonSponsorshipRepository: ISeasonSponsorshipRepository;
|
||||
sponsorshipRequestRepository: ISponsorshipRequestRepository;
|
||||
leagueWalletRepository: ILeagueWalletRepository;
|
||||
transactionRepository: ITransactionRepository;
|
||||
protestRepository: IProtestRepository;
|
||||
penaltyRepository: IPenaltyRepository;
|
||||
raceRepository: IRaceRepository;
|
||||
resultRepository: IResultRepository;
|
||||
standingRepository: IStandingRepository;
|
||||
@@ -22,6 +37,7 @@ export type RacingSeedDependencies = {
|
||||
raceRegistrationRepository: IRaceRegistrationRepository;
|
||||
teamRepository: ITeamRepository;
|
||||
teamMembershipRepository: ITeamMembershipRepository;
|
||||
sponsorRepository: ISponsorRepository;
|
||||
feedRepository: IFeedRepository;
|
||||
socialGraphRepository: ISocialGraphRepository;
|
||||
};
|
||||
@@ -41,6 +57,15 @@ export class SeedRacingData {
|
||||
|
||||
const seed = createRacingSeed();
|
||||
|
||||
let sponsorshipRequestsSeededViaRepo = false;
|
||||
const seedableSponsorshipRequests = this.seedDeps
|
||||
.sponsorshipRequestRepository as unknown as { seed?: (input: unknown) => void };
|
||||
|
||||
if (typeof seedableSponsorshipRequests.seed === 'function') {
|
||||
seedableSponsorshipRequests.seed(seed.sponsorshipRequests);
|
||||
sponsorshipRequestsSeededViaRepo = true;
|
||||
}
|
||||
|
||||
for (const driver of seed.drivers) {
|
||||
try {
|
||||
await this.seedDeps.driverRepository.create(driver);
|
||||
@@ -57,6 +82,65 @@ export class SeedRacingData {
|
||||
}
|
||||
}
|
||||
|
||||
for (const season of seed.seasons) {
|
||||
try {
|
||||
await this.seedDeps.seasonRepository.create(season);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const sponsorship of seed.seasonSponsorships) {
|
||||
try {
|
||||
await this.seedDeps.seasonSponsorshipRepository.create(sponsorship);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
if (!sponsorshipRequestsSeededViaRepo) {
|
||||
for (const request of seed.sponsorshipRequests) {
|
||||
try {
|
||||
await this.seedDeps.sponsorshipRequestRepository.create(request);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const wallet of seed.leagueWallets) {
|
||||
try {
|
||||
await this.seedDeps.leagueWalletRepository.create(wallet);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const tx of seed.leagueWalletTransactions) {
|
||||
try {
|
||||
await this.seedDeps.transactionRepository.create(tx);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const protest of seed.protests) {
|
||||
try {
|
||||
await this.seedDeps.protestRepository.create(protest);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const penalty of seed.penalties) {
|
||||
try {
|
||||
await this.seedDeps.penaltyRepository.create(penalty);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const race of seed.races) {
|
||||
try {
|
||||
await this.seedDeps.raceRepository.create(race);
|
||||
@@ -79,6 +163,14 @@ export class SeedRacingData {
|
||||
}
|
||||
}
|
||||
|
||||
for (const request of seed.leagueJoinRequests) {
|
||||
try {
|
||||
await this.seedDeps.leagueMembershipRepository.saveJoinRequest(request);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const team of seed.teams) {
|
||||
try {
|
||||
await this.seedDeps.teamRepository.create(team);
|
||||
@@ -87,6 +179,14 @@ export class SeedRacingData {
|
||||
}
|
||||
}
|
||||
|
||||
for (const sponsor of seed.sponsors) {
|
||||
try {
|
||||
await this.seedDeps.sponsorRepository.create(sponsor);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const membership of seed.teamMemberships) {
|
||||
try {
|
||||
await this.seedDeps.teamMembershipRepository.saveMembership(membership);
|
||||
@@ -95,6 +195,14 @@ export class SeedRacingData {
|
||||
}
|
||||
}
|
||||
|
||||
for (const request of seed.teamJoinRequests) {
|
||||
try {
|
||||
await this.seedDeps.teamMembershipRepository.saveJoinRequest(request);
|
||||
} catch {
|
||||
// ignore duplicates
|
||||
}
|
||||
}
|
||||
|
||||
for (const registration of seed.raceRegistrations) {
|
||||
try {
|
||||
await this.seedDeps.raceRegistrationRepository.register(registration);
|
||||
|
||||
Reference in New Issue
Block a user