seed data
This commit is contained in:
18
adapters/bootstrap/racing/RacingFriendshipFactory.ts
Normal file
18
adapters/bootstrap/racing/RacingFriendshipFactory.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Driver } from '@core/racing/domain/entities/Driver';
|
||||
import type { Friendship } from './RacingSeed';
|
||||
|
||||
export class RacingFriendshipFactory {
|
||||
create(drivers: Driver[]): Friendship[] {
|
||||
const friendships: Friendship[] = [];
|
||||
|
||||
for (let i = 0; i < drivers.length; i++) {
|
||||
const driver = drivers[i]!;
|
||||
for (let offset = 1; offset <= 3; offset++) {
|
||||
const friend = drivers[(i + offset) % drivers.length]!;
|
||||
friendships.push({ driverId: driver.id, friendId: friend.id });
|
||||
}
|
||||
}
|
||||
|
||||
return friendships;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user