diff --git a/src/fetcher/bahn_expert.ts b/src/fetcher/bahn_expert.ts index 1e26c9f..891de09 100644 --- a/src/fetcher/bahn_expert.ts +++ b/src/fetcher/bahn_expert.ts @@ -113,8 +113,8 @@ export const getEvaByStation = async (station: string): Promise => await request(ApiModule.BAHN_EXPERT, '/iris/v2/abfahrten/[evaNumber]', { evaNumber: String(evaNumber), lookahead: lookahead ? String(lookahead) : null, lookbehind: lookbehind ? String(lookbehind) : null }, { ignoreStatusCodes: [404], cache: bahnExpertCache, cacheTTL: 60 * 10, useGetArguments: ['lookahead', 'lookbehind'] }) -export const getCoachSequence = async (trainNumber: number, departure: string, evaNumber: number): Promise => - await request(ApiModule.BAHN_EXPERT, '/reihung/v4/wagen/[trainNumber]', { trainNumber: String(trainNumber), departure, evaNumber: String(evaNumber) }, { ignoreStatusCodes: [404], cache: bahnExpertCache, cacheTTL: 60 * 5, useGetArguments: ['departure', 'evaNumber']}) +export const getCoachSequence = async (trainNumber: number, trainCategory: string, initialDeparture: string, departure: string, evaNumber: number): Promise => + await request(ApiModule.BAHN_EXPERT, '/coachSequence/v4/wagen/[trainNumber]', { trainNumber: String(trainNumber), category: trainCategory, initialDeparture, departure, evaNumber: String(evaNumber) }, { ignoreStatusCodes: [404], cache: bahnExpertCache, cacheTTL: 60 * 5, useGetArguments: ['initialDeparture', 'departure', 'evaNumber', 'category']}) export const getTrainDetails = async (trainName: string, station: number, date: string): Promise => await request(ApiModule.BAHN_EXPERT, '/hafas/v2/details/[trainName]', { trainName, station: String(station), date }, { cache: bahnExpertCache, cacheTTL: 60 * 3, useGetArguments: [ 'station', 'date'], ignoreStatusCodes: [404]}) \ No newline at end of file diff --git a/src/rabbit/fetch_coach_sequence.ts b/src/rabbit/fetch_coach_sequence.ts index d252496..fa99df5 100644 --- a/src/rabbit/fetch_coach_sequence.ts +++ b/src/rabbit/fetch_coach_sequence.ts @@ -5,7 +5,7 @@ import { getCoachSequence, getEvaByStation } from '../fetcher/bahn_expert.js' import { debug } from '../logger.js' import rabbitAsyncHandler from '../rabbitAsyncHandler.js' -type FetchCoachSequence = { trainId: number, trainNumber: number, trainType: string, evaDeparture: string, evaNumber: number } +type FetchCoachSequence = { trainId: number, trainNumber: number, trainType: string, evaDeparture: string, evaNumber: number, initialDeparture: string } const getTrainVehicle = async ( @@ -96,7 +96,7 @@ const createTrainTripVehicle = async (trainId: number, groupIndex: number, train export const fetch_coach_sequence = rabbitAsyncHandler(async (msg: FetchCoachSequence) => { debug(`Starting to fetch coach sequence for ${msg.trainType}${msg.trainNumber} (ID ${msg.trainId})`) - const coachSequence = await getCoachSequence(msg.trainNumber, msg.evaDeparture, msg.evaNumber) + const coachSequence = await getCoachSequence(msg.trainNumber, msg.trainType, msg.initialDeparture, msg.evaDeparture, msg.evaNumber) if (!coachSequence) return const vehicleGroups = coachSequence.sequence.groups.filter(e => +e.number == msg.trainNumber) diff --git a/src/rabbit/fetch_train_numbers.ts b/src/rabbit/fetch_train_numbers.ts index 54db6aa..90b1cea 100644 --- a/src/rabbit/fetch_train_numbers.ts +++ b/src/rabbit/fetch_train_numbers.ts @@ -63,6 +63,7 @@ export const fetch_train_numbers = rabbitAsyncHandler(async (msg: FetchTrainNumb trainId, trainNumber: +train.train.number, trainType: train.train.type, + initialDeparture: train.initialDeparture, evaDeparture: train.departure.scheduledTime, evaNumber })