1 Commits

Author SHA1 Message Date
457722a79c Set Docker host for deployment workflow 2026-02-23 12:39:33 -08:00
21 changed files with 50 additions and 141 deletions

4
Caddyfile Normal file
View File

@@ -0,0 +1,4 @@
interchange-api.bchen.dev {
reverse_proxy app:4000
}

View File

@@ -19,8 +19,6 @@ services:
build: . build: .
command: npm run start command: npm run start
restart: unless-stopped restart: unless-stopped
ports:
- "4000:4000"
depends_on: depends_on:
- redis - redis
environment: environment:
@@ -36,6 +34,18 @@ services:
- ./redis-stack.conf:/redis-stack.conf - ./redis-stack.conf:/redis-stack.conf
command: redis-stack-server /redis-stack.conf command: redis-stack-server /redis-stack.conf
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes: volumes:
redis_data: redis_data:
caddy_data: caddy_data:

View File

@@ -6,7 +6,6 @@ scalar DateTime
type System { type System {
id: ID! id: ID!
name: String! name: String!
initialRegion: Region
routes: [Route!] routes: [Route!]
route(id: ID): Route route(id: ID): Route
stops: [Stop!] stops: [Stop!]
@@ -17,11 +16,6 @@ type System {
parkingSystem: ParkingSystem parkingSystem: ParkingSystem
} }
type Region {
topLeft: Coordinates!
bottomRight: Coordinates!
}
type ParkingSystem { type ParkingSystem {
systemId: ID! systemId: ID!
parkingStructures: [ParkingStructure!] parkingStructures: [ParkingStructure!]

View File

@@ -19,7 +19,6 @@ import { InMemoryExternalSourceETARepository } from "../repositories/shuttle/eta
import { ETAGetterRepository } from "../repositories/shuttle/eta/ETAGetterRepository"; import { ETAGetterRepository } from "../repositories/shuttle/eta/ETAGetterRepository";
import { InMemorySelfUpdatingETARepository } from "../repositories/shuttle/eta/InMemorySelfUpdatingETARepository"; import { InMemorySelfUpdatingETARepository } from "../repositories/shuttle/eta/InMemorySelfUpdatingETARepository";
import { BaseInMemoryETARepository } from "../repositories/shuttle/eta/BaseInMemoryETARepository"; import { BaseInMemoryETARepository } from "../repositories/shuttle/eta/BaseInMemoryETARepository";
import { IRegion } from "./SharedEntities";
export interface InterchangeSystemBuilderArguments { export interface InterchangeSystemBuilderArguments {
name: string; name: string;
@@ -50,12 +49,6 @@ export interface InterchangeSystemBuilderArguments {
* at a stop, in latitude/longitude degrees. * at a stop, in latitude/longitude degrees.
*/ */
shuttleStopArrivalDegreeDelta: number; shuttleStopArrivalDegreeDelta: number;
/**
* The initial map region to display when the app first loads
* this system. Represents a center coordinate and span.
*/
initialRegion?: IRegion;
} }
export class InterchangeSystem { export class InterchangeSystem {
@@ -69,7 +62,6 @@ export class InterchangeSystem {
public notificationRepository: NotificationRepository, public notificationRepository: NotificationRepository,
public parkingTimedDataLoader: TimedApiBasedRepositoryLoader | null, public parkingTimedDataLoader: TimedApiBasedRepositoryLoader | null,
public parkingRepository: ParkingGetterSetterRepository | null, public parkingRepository: ParkingGetterSetterRepository | null,
public initialRegion: IRegion | null,
) { ) {
} }
@@ -91,7 +83,7 @@ export class InterchangeSystem {
); );
notificationScheduler.startListeningForUpdates(); notificationScheduler.startListeningForUpdates();
let { parkingRepository, timedParkingLoader } = await InterchangeSystem.buildRedisParkingLoaderAndRepository(args.parkingSystemId, args.id); let { parkingRepository, timedParkingLoader } = await InterchangeSystem.buildRedisParkingLoaderAndRepository(args.parkingSystemId);
timedParkingLoader?.start(); timedParkingLoader?.start();
return new InterchangeSystem( return new InterchangeSystem(
@@ -104,7 +96,6 @@ export class InterchangeSystem {
notificationRepository, notificationRepository,
timedParkingLoader, timedParkingLoader,
parkingRepository, parkingRepository,
args.initialRegion ?? null,
); );
} }
@@ -145,7 +136,7 @@ export class InterchangeSystem {
shuttleRepository: ShuttleGetterRepository, shuttleRepository: ShuttleGetterRepository,
args: InterchangeSystemBuilderArguments args: InterchangeSystemBuilderArguments
) { ) {
const notificationRepository = new RedisNotificationRepository(undefined, args.id); const notificationRepository = new RedisNotificationRepository();
await notificationRepository.connect(); await notificationRepository.connect();
const notificationScheduler = new ETANotificationScheduler( const notificationScheduler = new ETANotificationScheduler(
etaRepository, etaRepository,
@@ -157,12 +148,12 @@ export class InterchangeSystem {
return { notificationScheduler, notificationRepository }; return { notificationScheduler, notificationRepository };
} }
private static async buildRedisParkingLoaderAndRepository(id?: string, systemId: string = '') { private static async buildRedisParkingLoaderAndRepository(id?: string) {
if (id === undefined) { if (id === undefined) {
return { parkingRepository: null, timedParkingLoader: null }; return { parkingRepository: null, timedParkingLoader: null };
} }
let parkingRepository: RedisParkingRepository | null = new RedisParkingRepository(undefined, systemId); let parkingRepository: RedisParkingRepository | null = new RedisParkingRepository();
await parkingRepository.connect(); await parkingRepository.connect();
const loaderBuilderArguments: ParkingRepositoryLoaderBuilderArguments = { const loaderBuilderArguments: ParkingRepositoryLoaderBuilderArguments = {
@@ -214,7 +205,6 @@ export class InterchangeSystem {
notificationRepository, notificationRepository,
timedParkingLoader, timedParkingLoader,
parkingRepository, parkingRepository,
args.initialRegion ?? null,
); );
} }

View File

@@ -11,8 +11,3 @@ export interface ICoordinates {
longitude: number; longitude: number;
} }
export interface IRegion {
topLeft: ICoordinates;
bottomRight: ICoordinates;
}

View File

@@ -25,10 +25,6 @@ const supportedSystems: InterchangeSystemBuilderArguments[] = [
name: "Chapman University", name: "Chapman University",
useSelfUpdatingEtas: true, useSelfUpdatingEtas: true,
shuttleStopArrivalDegreeDelta: 0.001, shuttleStopArrivalDegreeDelta: 0.001,
initialRegion: {
topLeft: { latitude: 33.85733, longitude: -117.89553 },
bottomRight: { latitude: 33.73970, longitude: -117.81878 },
},
} }
] ]

View File

@@ -4,23 +4,17 @@ import createRedisClientForRepository from '../helpers/createRedisClientForRepos
export abstract class BaseRedisRepository extends EventEmitter { export abstract class BaseRedisRepository extends EventEmitter {
protected redisClient; protected redisClient;
protected readonly systemId: string;
constructor( constructor(
redisClient: RedisClientType = createRedisClientForRepository(), redisClient: RedisClientType = createRedisClientForRepository(),
systemId: string = '',
) { ) {
super(); super();
this.redisClient = redisClient; this.redisClient = redisClient;
this.systemId = systemId;
this.redisClient.on('error', (err) => { this.redisClient.on('error', (err) => {
console.error(err.stack); console.error(err.stack);
}); });
} }
protected prefixKey = (key: string): string =>
this.systemId ? `${this.systemId}:${key}` : key;
get isReady() { get isReady() {
return this.redisClient.isReady; return this.redisClient.isReady;
} }

View File

@@ -1,4 +1,3 @@
import { RedisClientType } from 'redis';
import { TupleKey } from '../../types/TupleKey'; import { TupleKey } from '../../types/TupleKey';
import { import {
Listener, Listener,
@@ -8,22 +7,14 @@ import {
ScheduledNotification ScheduledNotification
} from "./NotificationRepository"; } from "./NotificationRepository";
import { BaseRedisRepository } from "../BaseRedisRepository"; import { BaseRedisRepository } from "../BaseRedisRepository";
import createRedisClientForRepository from '../../helpers/createRedisClientForRepository';
export class RedisNotificationRepository extends BaseRedisRepository implements NotificationRepository { export class RedisNotificationRepository extends BaseRedisRepository implements NotificationRepository {
private notificationListeners: Listener[] = []; private notificationListeners: Listener[] = [];
private readonly NOTIFICATION_KEY_PREFIX = 'notification:'; private readonly NOTIFICATION_KEY_PREFIX = 'notification:';
constructor(
redisClient: RedisClientType = createRedisClientForRepository(),
systemId: string = '',
) {
super(redisClient, systemId);
}
private getNotificationKey = (shuttleId: string, stopId: string): string => { private getNotificationKey = (shuttleId: string, stopId: string): string => {
const tuple = new TupleKey(shuttleId, stopId); const tuple = new TupleKey(shuttleId, stopId);
return this.prefixKey(`${this.NOTIFICATION_KEY_PREFIX}${tuple.toString()}`); return `${this.NOTIFICATION_KEY_PREFIX}${tuple.toString()}`;
}; };
public addOrUpdateNotification = async (notification: ScheduledNotification): Promise<void> => { public addOrUpdateNotification = async (notification: ScheduledNotification): Promise<void> => {

View File

@@ -28,7 +28,7 @@ class RedisNotificationRepositoryHolder implements RepositoryHolder {
url: process.env.REDIS_URL, url: process.env.REDIS_URL,
}); });
await this.redisClient.connect(); await this.redisClient.connect();
this.repo = new RedisNotificationRepository(this.redisClient, 'test-system'); this.repo = new RedisNotificationRepository(this.redisClient);
return this.repo; return this.repo;
} }
teardown = async () => { teardown = async () => {

View File

@@ -3,8 +3,6 @@ import { IParkingStructure } from "../../entities/ParkingRepositoryEntities";
import { HistoricalParkingAverageQueryResult, HistoricalParkingAverageFilterArguments } from "./ParkingGetterRepository"; import { HistoricalParkingAverageQueryResult, HistoricalParkingAverageFilterArguments } from "./ParkingGetterRepository";
import { BaseRedisRepository } from "../BaseRedisRepository"; import { BaseRedisRepository } from "../BaseRedisRepository";
import { PARKING_LOGGING_INTERVAL_MS } from "../../environment"; import { PARKING_LOGGING_INTERVAL_MS } from "../../environment";
import { RedisClientType } from "redis";
import createRedisClientForRepository from "../../helpers/createRedisClientForRepository";
export type ParkingStructureID = string; export type ParkingStructureID = string;
@@ -12,13 +10,6 @@ export class RedisParkingRepository extends BaseRedisRepository implements Parki
private dataLastAdded: Map<ParkingStructureID, Date> = new Map(); private dataLastAdded: Map<ParkingStructureID, Date> = new Map();
private loggingIntervalMs = PARKING_LOGGING_INTERVAL_MS; private loggingIntervalMs = PARKING_LOGGING_INTERVAL_MS;
constructor(
redisClient: RedisClientType = createRedisClientForRepository(),
systemId: string = '',
) {
super(redisClient, systemId);
}
addOrUpdateParkingStructure = async (structure: IParkingStructure): Promise<void> => { addOrUpdateParkingStructure = async (structure: IParkingStructure): Promise<void> => {
const keys = this.createRedisKeys(structure.id); const keys = this.createRedisKeys(structure.id);
await this.redisClient.hSet(keys.structure, this.createRedisHashFromStructure(structure)); await this.redisClient.hSet(keys.structure, this.createRedisHashFromStructure(structure));
@@ -37,8 +28,8 @@ export class RedisParkingRepository extends BaseRedisRepository implements Parki
}; };
clearParkingStructureData = async (): Promise<void> => { clearParkingStructureData = async (): Promise<void> => {
const structureKeys = await this.redisClient.keys(this.prefixKey('parking:structure:*')); const structureKeys = await this.redisClient.keys('parking:structure:*');
const timeSeriesKeys = await this.redisClient.keys(this.prefixKey('parking:timeseries:*')); const timeSeriesKeys = await this.redisClient.keys('parking:timeseries:*');
const allKeys = [...structureKeys, ...timeSeriesKeys]; const allKeys = [...structureKeys, ...timeSeriesKeys];
if (allKeys.length > 0) { if (allKeys.length > 0) {
@@ -60,7 +51,7 @@ export class RedisParkingRepository extends BaseRedisRepository implements Parki
}; };
getParkingStructures = async (): Promise<IParkingStructure[]> => { getParkingStructures = async (): Promise<IParkingStructure[]> => {
const keys = await this.redisClient.keys(this.prefixKey('parking:structure:*')); const keys = await this.redisClient.keys('parking:structure:*');
const structures: IParkingStructure[] = []; const structures: IParkingStructure[] = [];
for (const key of keys) { for (const key of keys) {
@@ -89,8 +80,8 @@ export class RedisParkingRepository extends BaseRedisRepository implements Parki
}; };
private createRedisKeys = (structureId: string) => ({ private createRedisKeys = (structureId: string) => ({
structure: this.prefixKey(`parking:structure:${structureId}`), structure: `parking:structure:${structureId}`,
timeSeries: this.prefixKey(`parking:timeseries:${structureId}`), timeSeries: `parking:timeseries:${structureId}`
}); });
private createRedisHashFromStructure = (structure: IParkingStructure): Record<string, string> => ({ private createRedisHashFromStructure = (structure: IParkingStructure): Record<string, string> => ({

View File

@@ -25,7 +25,7 @@ class RedisParkingRepositoryHolder implements RepositoryHolder<ParkingGetterSett
url: process.env.REDIS_URL, url: process.env.REDIS_URL,
}); });
await this.redisClient.connect(); await this.redisClient.connect();
this.repo = new RedisParkingRepository(this.redisClient, 'test-system'); this.repo = new RedisParkingRepository(this.redisClient);
return this.repo; return this.repo;
}; };
teardown = async () => { teardown = async () => {

View File

@@ -17,9 +17,8 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
constructor( constructor(
redisClient: RedisClientType = createRedisClientForRepository(), redisClient: RedisClientType = createRedisClientForRepository(),
readonly shuttleStopArrivalDegreeDelta: number = 0.001, readonly shuttleStopArrivalDegreeDelta: number = 0.001,
systemId: string = '',
) { ) {
super(redisClient, systemId); super(redisClient);
} }
get isReady() { get isReady() {
@@ -84,24 +83,24 @@ export class RedisShuttleRepository extends BaseRedisRepository implements Shutt
} }
// Key prefixes for individual entity keys // Key prefixes for individual entity keys
private get stopKeyPrefix() { return this.prefixKey('shuttle:stop:'); } private readonly stopKeyPrefix = 'shuttle:stop:';
private get routeKeyPrefix() { return this.prefixKey('shuttle:route:'); } private readonly routeKeyPrefix = 'shuttle:route:';
private get shuttleKeyPrefix() { return this.prefixKey('shuttle:shuttle:'); } private readonly shuttleKeyPrefix = 'shuttle:shuttle:';
private get orderedStopKeyPrefix() { return this.prefixKey('shuttle:orderedstop:'); } private readonly orderedStopKeyPrefix = 'shuttle:orderedstop:';
private get lastStopKeyPrefix() { return this.prefixKey('shuttle:laststop:'); } private readonly lastStopKeyPrefix = 'shuttle:laststop:';
private get historicalEtaKeyPrefix() { return this.prefixKey('shuttle:eta:historical:'); } private readonly historicalEtaKeyPrefix = 'shuttle:eta:historical:';
// Key patterns for bulk operations (e.g., getting all keys, clearing data) // Key patterns for bulk operations (e.g., getting all keys, clearing data)
private get stopKeyPattern() { return this.prefixKey('shuttle:stop:*'); } private readonly stopKeyPattern = 'shuttle:stop:*';
private get routeKeyPattern() { return this.prefixKey('shuttle:route:*'); } private readonly routeKeyPattern = 'shuttle:route:*';
private get shuttleKeyPattern() { return this.prefixKey('shuttle:shuttle:*'); } private readonly shuttleKeyPattern = 'shuttle:shuttle:*';
private get orderedStopKeyPattern() { return this.prefixKey('shuttle:orderedstop:*'); } private readonly orderedStopKeyPattern = 'shuttle:orderedstop:*';
private get lastStopKeyPattern() { return this.prefixKey('shuttle:laststop:*'); } private readonly lastStopKeyPattern = 'shuttle:laststop:*';
/** /**
* Represents a set storing the shuttles that are currently at a stop. * Represents a set storing the shuttles that are currently at a stop.
*/ */
private get shuttleIsAtStopKey() { return this.prefixKey('shuttle:atstop'); } private readonly shuttleIsAtStopKey = 'shuttle:atstop';
// Helper methods for Redis key generation // Helper methods for Redis key generation
private readonly createStopKey = (stopId: string) => `${this.stopKeyPrefix}${stopId}`; private readonly createStopKey = (stopId: string) => `${this.stopKeyPrefix}${stopId}`;

View File

@@ -31,7 +31,7 @@ class RedisShuttleRepositoryHolder implements RepositoryHolder<ShuttleGetterSett
url: process.env.REDIS_URL, url: process.env.REDIS_URL,
}); });
await this.redisClient.connect(); await this.redisClient.connect();
this.repo = new RedisShuttleRepository(this.redisClient, 0.001, 'test-system'); this.repo = new RedisShuttleRepository(this.redisClient);
return this.repo; return this.repo;
}; };
teardown = async () => { teardown = async () => {

View File

@@ -3,11 +3,11 @@ import { BaseRedisRepository } from "../../BaseRedisRepository";
import { ETAGetterRepository, ETARepositoryEvent, ETARepositoryEventListener, ETARepositoryEventName } from "./ETAGetterRepository"; import { ETAGetterRepository, ETARepositoryEvent, ETARepositoryEventListener, ETARepositoryEventName } from "./ETAGetterRepository";
export abstract class BaseRedisETARepository extends BaseRedisRepository implements ETAGetterRepository { export abstract class BaseRedisETARepository extends BaseRedisRepository implements ETAGetterRepository {
private get etaKeyPrefix() { return this.prefixKey('shuttle:eta:'); } private static readonly ETA_KEY_PREFIX = 'shuttle:eta:';
// Helper methods // Helper methods
protected createEtaKey = (shuttleId: string, stopId: string) => protected createEtaKey = (shuttleId: string, stopId: string) =>
`${this.etaKeyPrefix}${shuttleId}:${stopId}`; `${BaseRedisETARepository.ETA_KEY_PREFIX}${shuttleId}:${stopId}`;
createRedisHashFromEta = (eta: IEta): Record<string, string> => ({ createRedisHashFromEta = (eta: IEta): Record<string, string> => ({
secondsRemaining: eta.secondsRemaining.toString(), secondsRemaining: eta.secondsRemaining.toString(),
@@ -27,7 +27,7 @@ export abstract class BaseRedisETARepository extends BaseRedisRepository impleme
// Getter implementations // Getter implementations
async getEtasForShuttleId(shuttleId: string): Promise<IEta[]> { async getEtasForShuttleId(shuttleId: string): Promise<IEta[]> {
const keys = await this.redisClient.keys(`${this.etaKeyPrefix}${shuttleId}:*`); const keys = await this.redisClient.keys(`${BaseRedisETARepository.ETA_KEY_PREFIX}${shuttleId}:*`);
const etas: IEta[] = []; const etas: IEta[] = [];
for (const key of keys) { for (const key of keys) {
@@ -41,7 +41,7 @@ export abstract class BaseRedisETARepository extends BaseRedisRepository impleme
} }
async getEtasForStopId(stopId: string): Promise<IEta[]> { async getEtasForStopId(stopId: string): Promise<IEta[]> {
const keys = await this.redisClient.keys(`${this.etaKeyPrefix}*`); const keys = await this.redisClient.keys(`${BaseRedisETARepository.ETA_KEY_PREFIX}*`);
const etas: IEta[] = []; const etas: IEta[] = [];
for (const key of keys) { for (const key of keys) {

View File

@@ -2,17 +2,8 @@ import { IEta } from "../../../entities/ShuttleRepositoryEntities";
import { BaseRedisETARepository } from "./BaseRedisETARepository"; import { BaseRedisETARepository } from "./BaseRedisETARepository";
import { ExternalSourceETARepository } from "./ExternalSourceETARepository"; import { ExternalSourceETARepository } from "./ExternalSourceETARepository";
import { ETARepositoryEvent } from "./ETAGetterRepository"; import { ETARepositoryEvent } from "./ETAGetterRepository";
import { RedisClientType } from "redis";
import createRedisClientForRepository from "../../../helpers/createRedisClientForRepository";
export class RedisExternalSourceETARepository extends BaseRedisETARepository implements ExternalSourceETARepository { export class RedisExternalSourceETARepository extends BaseRedisETARepository implements ExternalSourceETARepository {
constructor(
redisClient: RedisClientType = createRedisClientForRepository(),
systemId: string = '',
) {
super(redisClient, systemId);
}
async addOrUpdateEtaFromExternalSource(eta: IEta): Promise<void> { async addOrUpdateEtaFromExternalSource(eta: IEta): Promise<void> {
await this.addOrUpdateEta(eta); await this.addOrUpdateEta(eta);
} }

View File

@@ -13,9 +13,8 @@ export class RedisSelfUpdatingETARepository extends BaseRedisETARepository imple
readonly shuttleRepository: ShuttleGetterRepository, readonly shuttleRepository: ShuttleGetterRepository,
redisClient: RedisClientType = createRedisClientForRepository(), redisClient: RedisClientType = createRedisClientForRepository(),
private referenceTime: Date | null = null, private referenceTime: Date | null = null,
systemId: string = '',
) { ) {
super(redisClient, systemId); super(redisClient);
this.setReferenceTime = this.setReferenceTime.bind(this); this.setReferenceTime = this.setReferenceTime.bind(this);
this.getAverageTravelTimeSeconds = this.getAverageTravelTimeSeconds.bind(this); this.getAverageTravelTimeSeconds = this.getAverageTravelTimeSeconds.bind(this);
@@ -29,7 +28,7 @@ export class RedisSelfUpdatingETARepository extends BaseRedisETARepository imple
} }
private createHistoricalEtaTimeSeriesKey = (routeId: string, fromStopId: string, toStopId: string) => { private createHistoricalEtaTimeSeriesKey = (routeId: string, fromStopId: string, toStopId: string) => {
return this.prefixKey(`shuttle:eta:historical:${routeId}:${fromStopId}:${toStopId}`); return `shuttle:eta:historical:${routeId}:${fromStopId}:${toStopId}`;
} }
setReferenceTime(referenceTime: Date) { setReferenceTime(referenceTime: Date) {

View File

@@ -16,7 +16,7 @@ class RedisExternalSourceETARepositoryHolder implements RepositoryHolder<Externa
url: process.env.REDIS_URL, url: process.env.REDIS_URL,
}); });
await this.redisClient.connect(); await this.redisClient.connect();
this.repo = new RedisExternalSourceETARepository(this.redisClient, 'test-system'); this.repo = new RedisExternalSourceETARepository(this.redisClient);
return this.repo; return this.repo;
} }
teardown = async () => { teardown = async () => {

View File

@@ -22,12 +22,10 @@ class RedisSelfUpdatingETARepositoryHolder implements RepositoryHolder<SelfUpdat
}); });
await this.redisClient.connect(); await this.redisClient.connect();
await this.redisClient.flushAll(); await this.redisClient.flushAll();
this.shuttleRepo = new RedisShuttleRepository(this.redisClient, 0.001, 'test-system'); this.shuttleRepo = new RedisShuttleRepository(this.redisClient);
this.repo = new RedisSelfUpdatingETARepository( this.repo = new RedisSelfUpdatingETARepository(
this.shuttleRepo, this.shuttleRepo,
this.redisClient, this.redisClient,
null,
'test-system',
); );
return this.repo; return this.repo;
} }

View File

@@ -83,14 +83,6 @@ export const SystemResolvers: Resolvers<ServerContext> = {
const shuttles = await system.shuttleRepository.getShuttles(); const shuttles = await system.shuttleRepository.getShuttles();
return shuttles.slice().sort((a, b) => a.name.localeCompare(b.name)); return shuttles.slice().sort((a, b) => a.name.localeCompare(b.name));
}, },
initialRegion: async (parent, _args, contextValue, _info) => {
const system = contextValue.findSystemById(parent.id);
if (!system) {
return null;
}
return system.initialRegion;
},
parkingSystem: async (parent, _args, contextValue, _info) => { parkingSystem: async (parent, _args, contextValue, _info) => {
const system = contextValue.findSystemById(parent.id); const system = contextValue.findSystemById(parent.id);
if (!system) { if (!system) {

View File

@@ -35,37 +35,6 @@ describe("SystemResolvers", () => {
}); });
} }
describe("initialRegion", () => {
const query = `
query GetSystemInitialRegion($systemId: ID!) {
system(id: $systemId) {
initialRegion {
topLeft {
latitude
longitude
}
bottomRight {
latitude
longitude
}
}
}
}
`;
it("returns the initial region for the system", async () => {
const response = await getResponseFromQueryNeedingSystemId(query);
assert(response.body.kind === "single");
expect(response.body.singleResult.errors).toBeUndefined();
const initialRegion = (response.body.singleResult.data as any).system.initialRegion;
expect(initialRegion).toEqual({
topLeft: { latitude: 33.85733, longitude: -117.89553 },
bottomRight: { latitude: 33.7397, longitude: -117.81878 },
});
});
});
describe("routes", () => { describe("routes", () => {
const query = ` const query = `
query GetSystemRoutes($systemId: ID!) { query GetSystemRoutes($systemId: ID!) {

View File

@@ -26,10 +26,6 @@ const systemInfoForTesting: InterchangeSystemBuilderArguments = {
parkingSystemId: ChapmanApiBasedParkingRepositoryLoader.id, parkingSystemId: ChapmanApiBasedParkingRepositoryLoader.id,
useSelfUpdatingEtas: false, useSelfUpdatingEtas: false,
shuttleStopArrivalDegreeDelta: 0.001, shuttleStopArrivalDegreeDelta: 0.001,
initialRegion: {
topLeft: { latitude: 33.85733, longitude: -117.89553 },
bottomRight: { latitude: 33.73970, longitude: -117.81878 },
},
}; };
export function buildSystemForTesting() { export function buildSystemForTesting() {