From ee75bc6976b525d90aee71f4fd80c0618a18d858 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Fri, 21 Oct 2022 21:05:53 +0000 Subject: [PATCH] Changing caching parameters, fix checkin dates --- resources/views/tracker.blade.php | 2 +- routes/web.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index f2fbaa1..ee0767c 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -56,7 +56,7 @@

{{ $checkin->title ?? "[No title]" }}

-

{!! render_date_difference($trip->updated_at) !!}

+

{!! render_date_difference($checkin->date) !!}

{{ $checkin->note ?? "[No note]" }} @if($checkin->image_url) diff --git a/routes/web.php b/routes/web.php index 9c78d25..1b61799 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,8 +15,8 @@ Route::get('/{tripId?}', function (Request $request, $tripId = null) { $viewMode = $request->input('show', null); /* - * If there is a file in the local cache that is less than 3 hours old, - * use that. + * If there is a file in the local cache that is less than 1–3 hours old + * (depending on whether it was actively tracking at last check), use that. */ $tripFileName = ( $tripId ?? config('app.current_trip_id') ) . '.json'; if (Storage::disk('local')->exists($tripFileName)) { @@ -24,7 +24,7 @@ Route::get('/{tripId?}', function (Request $request, $tripId = null) { if ($cachedData->trip->is_active) { $cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at); $now = new DateTime(); - if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 3) { + if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= ($cachedData->trip->is_tracking) ? 1 : 3) { return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]); } } else {