Skip to content

Commit 25fa1e7

Browse files
authored
🐛 Fix a few bugs (#3611)
1 parent 779203f commit 25fa1e7

File tree

9 files changed

+18
-10
lines changed

9 files changed

+18
-10
lines changed

app/DataProviders/Motis.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ private function fetchJourney(string $tripId): array|null {
258258
}
259259

260260
} catch (Exception $exception) {
261+
if (!empty($response) && str_contains(strtolower($response->body()), 'trip not found')) {
262+
Log::debug('MOTIS Trip not found', ['tripId' => $tripId]);
263+
return null;
264+
}
265+
261266
CacheKey::increment(HCK::TRIPS_FAILURE);
262267
Log::error('Unknown HAFAS Error (fetchJourney)', [
263268
'status' => $response->status(),

app/DataProviders/Repositories/MotisLicenseRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function getLicense(string $gtfsSource, DataProvider $source): ?MotisSour
1414
$name = $matches['name'] ?? '';
1515
$country = $matches['country'] ?? '';
1616
if (empty($name) || empty($country)) {
17-
Log::error('no matching license format found in ' . $gtfsSource);
17+
Log::warning('no matching license format found in ' . $gtfsSource);
1818
return null;
1919
}
2020

app/Http/Controllers/API/v1/TripController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public function createTrip(ManualTripCreationRequest $request): TripResource|Jso
3131
$creator = new ManualTripCreator();
3232
$creator->setCategory(HafasTravelType::from($validated['category']))
3333
->setLine($validated['lineName'], $validated['journeyNumber'])
34-
->setOperator(HafasOperator::find($validated['operatorId']))
3534
->setOrigin(
3635
Station::findOrFail($validated['originId']),
3736
Carbon::parse($validated['originDeparturePlanned']),
@@ -43,6 +42,11 @@ public function createTrip(ManualTripCreationRequest $request): TripResource|Jso
4342
isset($validated['destinationArrivalReal']) ? Carbon::parse($validated['destinationArrivalReal']) : null
4443
);
4544

45+
if (isset($validated['operatorId'])) {
46+
$operator = HafasOperator::findOrFail($validated['operatorId']);
47+
$creator->setOperator($operator);
48+
}
49+
4650
foreach ($validated['stopovers'] ?? [] as $stopover) {
4751
$creator->addStopover(
4852
Station::findOrFail($stopover['stationId']),

app/Http/Controllers/API/v1/WebhookController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
namespace App\Http\Controllers\API\v1;
44

55
use App\Http\Controllers\API\v1\Controller as APIController;
6-
use App\Http\Controllers\Backend\WebhookController as WebhookBackend;
76
use App\Http\Resources\WebhookResource;
87
use App\Models\Webhook;
98
use Illuminate\Auth\Access\AuthorizationException;
10-
use Illuminate\Database\Eloquent\ModelNotFoundException;
119
use Illuminate\Http\JsonResponse;
12-
use Illuminate\Http\Request;
1310
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
1411

1512
class WebhookController extends Controller
@@ -135,7 +132,7 @@ private function getWebhookForUserAndCurrentClient(int $webhookId): ?Webhook {
135132

136133
$query = Webhook::where('user_id', auth()->id());
137134
if ($currentClient !== null) { // null = Traewelling itself or personal access token
138-
$query->where('client_id', $currentClient->id);
135+
$query->where('oauth_client_id', $currentClient->id);
139136
}
140137

141138
return $query->where('id', '=', $webhookId)->first();

app/Http/Controllers/Backend/Support/LocationController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ private function createPolylineFromStopovers(): FeatureCollection {
231231
$coordinate = new Coordinate($stopover->station->latitude, $stopover->station->longitude);
232232
$feature = Feature::fromCoordinate($coordinate);
233233
$feature->setStationId($stopover->station->id);
234-
$feature->setDeparturePlanned($stopover->departure_planned->toIso8601ZuluString());
235-
$feature->setArrivalPlanned($stopover->arrival_planned->toIso8601ZuluString());
234+
$feature->setDeparturePlanned($stopover->departure_planned?->toIso8601ZuluString());
235+
$feature->setArrivalPlanned($stopover->arrival_planned?->toIso8601ZuluString());
236236
$coordinates[] = $feature;
237237

238238

app/Http/Controllers/Backend/Transport/ManualTripCreator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ManualTripCreator extends Controller
2323
private HafasTravelType $category;
2424
private string $lineName;
2525
private ?int $journeyNumber;
26-
private ?HafasOperator $operator;
26+
private ?HafasOperator $operator = null;
2727
private Station $origin;
2828
private Carbon $originDeparturePlanned;
2929
private ?Carbon $originDepartureReal;

app/Http/Controllers/SitemapController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private function addEvents(Sitemap $sitemap): void {
6666

6767
$eventIdsWithCheckins = Status::whereNotNull('event_id')->select('event_id');
6868
$events = Event::whereIn('id', $eventIdsWithCheckins)
69-
->orWhere('end', '>=', DB::raw('CURRENT_TIMESTAMP'))
69+
->orWhere('event_end', '>=', DB::raw('CURRENT_TIMESTAMP'))
7070
->get();
7171

7272
foreach ($events as $event) {

lang/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@
618618
"stats.stations.description": "Karte deiner durchfahrenen Stationen",
619619
"stats.stations.passed": "Durchgefahrene Station",
620620
"stats.stations.changed": "Einstieg / Ausstieg / Umstieg",
621+
"stats.daily": "Tägliche Fahrten",
621622
"stats.daily.description": "Tagebuch deiner Fahrten inkl. Karte",
622623
"warning.insecure-performance": "Die Ladezeit dieser Seite ist ggfs. bei vielen Daten sehr langsam.",
623624
"year-review": "Jahresrückblick",

lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@
621621
"stats.stations.description": "Map of your passed stations",
622622
"stats.stations.passed": "Passed station",
623623
"stats.stations.changed": "Entry / Exit / Change",
624+
"stats.daily": "Daily statistics",
624625
"stats.daily.description": "Diary of your journeys incl. map",
625626
"warning.insecure-performance": "The loading time of this page may be very slow if there is a lot of data.",
626627
"year-review": "Year in review",

0 commit comments

Comments
 (0)