Skip to content

Commit

Permalink
✨ Get trip number from first stop of journey (#3134)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebiIO authored Jan 11, 2025
1 parent 884f48e commit 29820d2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/DataProviders/Bahn.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,14 @@ public function fetchHafasTrip(string $tripID, string $lineName): Trip {
}

$tripLineName = $cachedData['lineName'] ?? '';
preg_match('/#ZE#(\d+)/', $tripID, $matches);
$tripNumber = 0;
if (count($matches) > 1) {
$tripNumber = $matches[1];

// get trip number from first stop
$tripNumber = isset($rawJourney['halte'][0]['nummer']) ? (int) $rawJourney['halte'][0]['nummer'] : 0;
if ($tripNumber === 0) {
preg_match('/#ZE#(\d+)/', $tripID, $matches);
if (count($matches) > 1) {
$tripNumber = $matches[1];
}
}

$stopovers = collect();
Expand Down

0 comments on commit 29820d2

Please sign in to comment.