chess-centre/leagues

Prepare seed data

Closed this issue · 5 comments

Given the current scheme, the following mock data should be used to seed the local development environment, with a init() method available on start up.

This data has been lifted from the ECF LMS - Wharfedale Junior League

League

const league = await prisma.league.create({
  data: {
    id: 1,
    name: 'Wharfedale Junior League',
  }
});

Division(s)

const divisionOne = await prisma.division.create({
  data: {
    id: 1,
    name: 'Division One',
    leagueId: 1
  }
});

Season

const seasonOne = await prisma.season.create({
  data: {
    id: 1,
    displayName: '2022-23',
    start: `2022-09-01T00:00:00.000Z`,
    end: `2022-08-31T00:00:00.000Z`,
  }
});

Teams

const wharfedaleTeams = [
  {
    id: 1,
    name: "Mountain Lions",
    divisionId: 1,
  },
  .... // see PR
];
const teams = await prisma.playerRating.createMany({ data: wharfedaleTeams }));

Players

const wharfedalePlayers = [
  // Mountain Lions
  {
    id: 1,
    firstName: "Shriaansh",
    lastName: "Ganti",
    teamId: 1,
  },
  {
    id: 2,
    firstName: "Cora",
    lastName: "Wainwright",
    teamId: 1,
  },
  .... // see PR
];
const players = await prisma.player.createMany({ data: wharfedalePlayers }));

Ratings

const playerRatings = [
  // Mountain Lions
  {
    type: Federation.ECF,
    rating: 1154,
    playerId: 1
  },
  .... // see PR
];
const ratings = await prisma.playerRating.createMany({ data: playerRatings }));

Here is the current mapped Fixtures, as per the LMS:

Fixtures

const wharfedaleFixtures = [
  {
    id: 1,
    date: `2022-09-24T10:30:00.000Z`,
    seasonId: 1,
    divisionId: 1,
    homeTeamId: 3,
    awayTeamId: 1
  },
  {
    id: 2,
    date: `2022-09-24T10:30:00.000Z`,
    seasonId: 1,
    divisionId: 1,
    homeTeamId: 2,
    awayTeamId: 4
  },
  .... // see PR
];
const fixtures = await prisma.fixture.createMany({ data: wharfedaleFixtures }));

Results

const wharfedaleResults = [
  {
    id: 1,
    fixtureId: 1
  },
  {
    id: 2,
    fixtureId: 2
  },
  {
    id: 3,
    fixtureId: 3
  },
  {
    id: 4,
    fixtureId: 4
  }
];

@connersomerville Okay, so we have a challenge providing the data for the result.

I suspect, we need to move the players reference from the Fixtures model to the Results

Example match result data: https://ecflms.org.uk/lms/node/116383

We need an array of playerIds, or some representation of a match card so we can interogate the order of players:

FixtureId: 1
HomeTeamId: 3 // Leopards
AwayTeamId: 1 // Lions

Board 1. whitePlayerId: 12, result: "0-1", blackPlayerId: 1
Board 2. whitePlayerId: 13, result: "1-0", blackPlayerId: 4
Board 3. whitePlayerId: 14, result: "1-0", blackPlayerId: 3

Match result: 2 -1 // Home Team Win

Note: not all home teams will always have white on every board, sometime is alternatives White, Black, White, Black.