UNPKG

@golemio/pid

Version:
63 lines (62 loc) 3.36 kB
import { JISEventsRepository } from "../../../../jis/repositories/JISEventsRepository"; import type { TripsRepository } from "../../vehicle-positions/data-access/TripsRepository"; import { ISimpleConfig } from "@golemio/core/dist/helpers/configuration/ISimpleConfig"; import { ILogger } from "@golemio/core/dist/helpers/logger"; import { AbstractEmptyTask } from "@golemio/core/dist/integration-engine/workers"; import { PublicStopTimeCacheRepository } from "../../vehicle-positions/data-access/cache/PublicStopTimeCacheRepository"; import { GtfsRtRedisRepository } from "../data-access/GtfsRtRedisRepository"; export declare class GenerateFilesTask extends AbstractEmptyTask { private readonly config; private readonly logger; private readonly stopTimeRepository; private readonly tripsRepository; private readonly gtfsRtRedisRepository; private static readonly decoratorConfig; readonly queueName = "generateFiles"; readonly queueTtl: number; private readonly alertsGenerator; private readonly vehicleDescriptor; private lockTimeout; private refreshInterval; constructor(config: ISimpleConfig, logger: ILogger, jisEventsRepository: JISEventsRepository, stopTimeRepository: PublicStopTimeCacheRepository, tripsRepository: TripsRepository, gtfsRtRedisRepository: GtfsRtRedisRepository); protected execute(): Promise<void>; private logFinishTime; private readStopTimeIds; private speedMpsToKmh; private feedEntityFromTripData; private stopTimeUpdatesFromVehicleTrip; protected generateFiles(): Promise<void>; /** * Get rid of vehicle descriptors with duplicate IDs from a given GTFS-RT message * * @param message The message to get rid of duplicate vehicle descriptors from * @param tripData The trip data to get start timestamps from * @param options Options for the duplicate removal process * @param options.removeVehicleOnly Whether to only remove the duplicate vehicle descriptor from the message entity, instead * of removing the whole entity. Defaults to `false`. Note that if an entity with a duplicate vehicle descriptor does not * contain any other valuable data, it will be removed regardless of this option. */ private removeDuplicateVehicleDescriptors; /** * Update a given `EntityWithTripStartByVehicleId` Map with given values if the new entity has a lower trip start date/time * and is not canceled. The entity that does not end up in the map (either the new entity if it does not meet the conditions * for the update or the original entity if the new entity does) is returned. * * @param entityWithTripStartByVehicleId The Map to update * @param vehicleId The vehicle ID to use as a key * @param entity The entity to use as part of the new value, if the conditions are met * @param entityTripStart The entity trip start date/time to use as part of the new value, if the conditions are met */ private conditionallyUpdateEntityByVehicleId; private generateStopTimeUpdate; private createFeedHeader; /** * Parse UTC date from ISO timestamp * @example 20230101 */ private parseUTCDateFromISO; private validateAndSaveBuffer; private shouldFallbackToScheduleTime; private handleCanceledTrip; private createMutex; }