Skip to content

Commit

Permalink
Fix stop place -quay structure in seed data
Browse files Browse the repository at this point in the history
  • Loading branch information
culka committed Feb 4, 2025
1 parent 5e466e5 commit 8bd4e51
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 124 deletions.
27 changes: 9 additions & 18 deletions test-db-manager/src/datasets/stopRegistry/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import {
import { isNotNullish } from '../../utils';
import { InfoSpotInput } from './infoSpots';
import { StopAreaInput } from './stopArea';
import { QuayInput, StopPlaceMaintenance } from './stopPlaces';
import { StopPlaceMaintenance } from './stopPlaces';
import { TerminalInput } from './terminals';

export type StopDetails = {
export type QuayDetails = {
netexId: string;
shelters: Array<string>;
};

export type StopAreaIdsByName = Record<string, string>;
export type StopPlaceDetailsByLabel = Record<string, StopDetails>;
export type StopPlaceIdsByName = Record<string, string>;
export type QuayDetailsByLabel = Record<string, QuayDetails>;
export type TerminalIdsByName = Record<string, string>;
export type OrganisationIdsByName = Record<string, string>;

Expand Down Expand Up @@ -56,13 +56,6 @@ const mapStopPlaceMaintenanceToInput = (
return organisationRefs;
};

export const setStopPlaceQuays = (
input: StopAreaInput,
quays: Array<QuayInput>,
): StopAreaInput => {
return input;
};

export const setStopPlaceOrganisations = (
input: StopAreaInput,
organisationIdsByName: OrganisationIdsByName,
Expand All @@ -82,16 +75,14 @@ export const setStopPlaceOrganisations = (

export const buildTerminalCreateInput = (
input: TerminalInput,
stopPlaceDetailsByLabel: StopPlaceDetailsByLabel,
stopPlaceIdsByName: StopPlaceIdsByName,
): Partial<StopRegistryCreateMultiModalStopPlaceInput> => {
const terminal = {
name: input.terminal.name,
description: input.terminal.description,
validBetween: input.terminal.validBetween,
geometry: input.terminal.geometry,
stopPlaceIds: input.memberLabels.map(
(label) => stopPlaceDetailsByLabel[label].netexId,
),
stopPlaceIds: input.memberLabels.map((label) => stopPlaceIdsByName[label]),
};

return terminal;
Expand All @@ -109,7 +100,7 @@ export const buildTerminalUpdateInput = (

export const setInfoSpotRelations = (
input: InfoSpotInput,
stopPlaceDetailsByLabel: StopPlaceDetailsByLabel,
quayDetailsByLabel: QuayDetailsByLabel,
): Partial<StopRegistryInfoSpotInput> => {
const infoSpot: Partial<StopRegistryInfoSpotInput> = {
...input.infoSpot,
Expand All @@ -118,14 +109,14 @@ export const setInfoSpotRelations = (

if (input.locatedOnStopLabel) {
infoSpot.infoSpotLocations?.push(
stopPlaceDetailsByLabel[input.locatedOnStopLabel].netexId,
quayDetailsByLabel[input.locatedOnStopLabel].netexId,
);
if (
input.associatedShelter !== null &&
input.associatedShelter !== undefined
) {
infoSpot.infoSpotLocations?.push(
stopPlaceDetailsByLabel[input.locatedOnStopLabel].shelters[
quayDetailsByLabel[input.locatedOnStopLabel].shelters[
input.associatedShelter
],
);
Expand Down
6 changes: 6 additions & 0 deletions test-db-manager/src/datasets/stopRegistry/stopPlaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export const defaultAccessibilityLimitations: StopRegistryAccessibilityLimitatio
};

export type StopPlaceNetexRef = {
label: string;
netexId: string;
quayRef: Array<QuayNetexRef>;
};

export type QuayNetexRef = {
label: string;
netexId: string;
shelterRef: Array<string>;
Expand Down
8 changes: 1 addition & 7 deletions test-db-manager/src/datasets/stopRegistry/terminals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ const mapToTerminalInput = (seedTerminal: TerminalSeedData): TerminalInput => {
lang: 'fin',
value: seedTerminal.description,
},
validBetween: {
fromDate:
seedTerminal.validityStart ??
DateTime.fromISO('2020-01-01T00:00:00.001'),
toDate: null,
},
geometry: {
coordinates: [seedTerminal.locationLong, seedTerminal.locationLat],
type: StopRegistryGeoJsonType.Point,
Expand Down Expand Up @@ -94,7 +88,7 @@ const northEsplanadi = {
label: 'T1',
locationLat: 60.167836,
locationLong: 24.94905,
members: ['H2003'],
members: ['X1234'],
streetAddress: 'Mannerheimintie 22-24',
postalCode: '00100',
departurePlatforms: '7',
Expand Down
1 change: 1 addition & 0 deletions test-db-manager/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69037,6 +69037,7 @@ export type InsertStopPlaceMutation = {
quays?: Array<{
__typename?: 'stop_registry_Quay';
id?: string | null;
publicCode?: string | null;
placeEquipments?: {
__typename?: 'stop_registry_PlaceEquipments';
shelterEquipment?: Array<{
Expand Down
Loading

0 comments on commit 8bd4e51

Please sign in to comment.