fix cancelled state for exceptional cases

This commit is contained in:
Traines 2026-01-10 13:48:33 +00:00
parent 0c39991e0c
commit 6fa0abbde5
4 changed files with 33 additions and 33 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "db-vendo-client", "name": "db-vendo-client",
"version": "6.10.7", "version": "6.10.8",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "db-vendo-client", "name": "db-vendo-client",
"version": "6.10.7", "version": "6.10.8",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"content-type": "^1.0.5", "content-type": "^1.0.5",

View file

@ -1,7 +1,7 @@
{ {
"name": "db-vendo-client", "name": "db-vendo-client",
"description": "Client for bahn.de public transport APIs.", "description": "Client for bahn.de public transport APIs.",
"version": "6.10.7", "version": "6.10.8",
"type": "module", "type": "module",
"main": "index.js", "main": "index.js",
"files": [ "files": [

View file

@ -60,28 +60,28 @@ const parseRemarks = (ctx, ref) => {
}; };
/* /*
meldungenAsObject meldungenAsObject
{ {
"code": "MDA-AK-MSG-1000", "code": "MDA-AK-MSG-1000",
"nachrichtKurz": "Connection is in the past.", "nachrichtKurz": "Connection is in the past.",
"nachrichtLang": "Selected connection is in the past.", "nachrichtLang": "Selected connection is in the past.",
"fahrtRichtungKennzeichen": "HINFAHRT" "fahrtRichtungKennzeichen": "HINFAHRT"
} }
[ [
{ {
"code": "MDA-AK-MSG-3000", "code": "MDA-AK-MSG-3000",
"nachrichtKurz": "Booking not possible.", "nachrichtKurz": "Booking not possible.",
"nachrichtLang": "Booking is no longer possible for the connection you selected", "nachrichtLang": "Booking is no longer possible for the connection you selected",
"fahrtRichtungKennzeichen": "HINFAHRT" "fahrtRichtungKennzeichen": "HINFAHRT"
} }
] ]
priorisierteMeldungen priorisierteMeldungen
{ {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"text": "ICE 597 departs differently from Mainz Hbf from Platform 1b" "text": "ICE 597 departs differently from Mainz Hbf from Platform 1b"
} }
[ [
{ {
"prioritaet": "NIEDRIG", "prioritaet": "NIEDRIG",
"text": "Advance notice! In the period from 15.12.24 to 17.01.25, construction work will take place between Mainz Hbf and Frankfurt(Main)Hbf. There will be changed run times and partial cancellation. Please inform yourself early on the Internet and at the stations." "text": "Advance notice! In the period from 15.12.24 to 17.01.25, construction work will take place between Mainz Hbf and Frankfurt(Main)Hbf. There will be changed run times and partial cancellation. Please inform yourself early on the Internet and at the stations."
@ -90,14 +90,14 @@ const parseRemarks = (ctx, ref) => {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"text": "The route between Mainz Hbf and Mainz Nord is currently closed. The reason is a repair on the track. At the moment, no train journeys are possible in the affected section of the route. As a result, there are now delays and partial failures. The trains terminates and starts unscheduled in Mainz Hbf. Please check your travel connections shortly before the train departs. This message will be updated as soon as we have more information." "text": "The route between Mainz Hbf and Mainz Nord is currently closed. The reason is a repair on the track. At the moment, no train journeys are possible in the affected section of the route. As a result, there are now delays and partial failures. The trains terminates and starts unscheduled in Mainz Hbf. Please check your travel connections shortly before the train departs. This message will be updated as soon as we have more information."
} }
] ]
[ [
{ {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"text": "Trip is not possible" "text": "Trip is not possible"
} }
] ]
[ [
{ {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"text": "Intervention by authorities" "text": "Intervention by authorities"
@ -106,44 +106,44 @@ const parseRemarks = (ctx, ref) => {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"text": "Switch repairs between Frankfurt(Main)Hbf and Mannheim Hbf delays rail transport. The train is diverted. The stop Mainz Hbf is cancelled. Please allow for a delay of up to 10 minutes. Please check for any changes to your journey prior to departure." "text": "Switch repairs between Frankfurt(Main)Hbf and Mannheim Hbf delays rail transport. The train is diverted. The stop Mainz Hbf is cancelled. Please allow for a delay of up to 10 minutes. Please check for any changes to your journey prior to departure."
} }
] ]
[ [
{ {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"text": "Stop cancelled", "text": "Stop cancelled",
"type": "HALT_AUSFALL" "type": "HALT_AUSFALL"
} }
] ]
risNotizen risNotizen
{ {
"key": "text.realtime.connection.platform.change", "key": "text.realtime.connection.platform.change",
"value": "ICE 597 departs differently from Mainz Hbf from Platform 1b" "value": "ICE 597 departs differently from Mainz Hbf from Platform 1b"
} }
{key: "FT", value: "Staff delayed due to earlier journey", routeIdxFrom: 0, routeIdxTo: 12} {key: "FT", value: "Staff delayed due to earlier journey", routeIdxFrom: 0, routeIdxTo: 12}
[ [
{ {
"key": "text.realtime.connection.cancelled", "key": "text.realtime.connection.cancelled",
"value": "Trip is not possible" "value": "Trip is not possible"
} }
] ]
[ [
{ {
"key": "FT", "key": "FT",
"value": "Intervention by authorities", "value": "Intervention by authorities",
"routeIdxFrom": 9, "routeIdxFrom": 9,
"routeIdxTo": 21 "routeIdxTo": 21
} }
] ]
[ [
{ {
"key": "text.realtime.stop.cancelled", "key": "text.realtime.stop.cancelled",
"value": "Stop cancelled" "value": "Stop cancelled"
} }
] ]
himMeldungen himMeldungen
[ [
{ {
"ueberschrift": "Construction work.", "ueberschrift": "Construction work.",
"text": "Advance notice! In the period from 15.12.24 to 17.01.25, construction work will take place between Mainz Hbf and Frankfurt(Main)Hbf. There will be changed run times and partial cancellation. Please inform yourself early on the Internet and at the stations.", "text": "Advance notice! In the period from 15.12.24 to 17.01.25, construction work will take place between Mainz Hbf and Frankfurt(Main)Hbf. There will be changed run times and partial cancellation. Please inform yourself early on the Internet and at the stations.",
@ -156,14 +156,14 @@ const parseRemarks = (ctx, ref) => {
"prioritaet": "HOCH", "prioritaet": "HOCH",
"modDateTime": "2024-12-06T06:24:35" "modDateTime": "2024-12-06T06:24:35"
} }
[ [
{ {
"ueberschrift": "Disruption.", "ueberschrift": "Disruption.",
"text": "Switch repairs between Frankfurt(Main)Hbf and Mannheim Hbf delays rail transport. The train is diverted. The stop Mainz Hbf is cancelled. Please allow for a delay of up to 10 minutes. Please check for any changes to your journey prior to departure.", "text": "Switch repairs between Frankfurt(Main)Hbf and Mannheim Hbf delays rail transport. The train is diverted. The stop Mainz Hbf is cancelled. Please allow for a delay of up to 10 minutes. Please check for any changes to your journey prior to departure.",
"prioritaet": "HOCH", "prioritaet": "HOCH",
"modDateTime": "2024-12-05T19:01:48" "modDateTime": "2024-12-05T19:01:48"
} }
] ]
zugattribute zugattribute
[ [
@ -213,7 +213,7 @@ const parseCancelled = (ref) => {
(ref.risNotizen || ref.echtzeitNotizen || ref.meldungen).find(r => r.key == 'text.realtime.stop.cancelled' (ref.risNotizen || ref.echtzeitNotizen || ref.meldungen).find(r => r.key == 'text.realtime.stop.cancelled'
|| r.type == 'HALT_AUSFALL' || r.type == 'HALT_AUSFALL'
|| r.text == 'Halt entfällt' || r.text == 'Halt entfällt'
|| r.text == 'Stop cancelled', || r.text?.includes('fällt aus') || r.text?.includes('cancelled'),
), ),
); );
}; };

View file

@ -6,7 +6,7 @@ const parseTrip = (ctx, t, id) => { // t = raw trip
trip.id = trip.tripId || id; trip.id = trip.tripId || id;
delete trip.tripId; delete trip.tripId;
delete trip.reachable; delete trip.reachable;
trip.cancelled = Boolean(profile.parseCancelled(t)); trip.cancelled = Boolean(profile.parseCancelled(t) || trip.stopovers?.length && trip.stopovers?.every(s => s.cancelled));
// TODO opt.scheduledDays // TODO opt.scheduledDays
return trip; return trip;