Changing caching parameters, fix checkin dates

This commit is contained in:
Ben Goldsworthy 2022-10-21 21:05:53 +00:00
parent 61d5f69699
commit ee75bc6976
2 changed files with 4 additions and 4 deletions

View file

@ -56,7 +56,7 @@
<details class="checkin" id="{{ $checkin->id }}" ontoggle="toggleCheckin(this.open, this.id)">
<summary class="checkin__summary">
<h2 class="checkin__title">{{ $checkin->title ?? "[No title]" }}</h2>
<p class="checkin__meta">{!! render_date_difference($trip->updated_at) !!}</p>
<p class="checkin__meta">{!! render_date_difference($checkin->date) !!}</p>
</summary>
{{ $checkin->note ?? "[No note]" }}
@if($checkin->image_url)

View file

@ -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 13 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 {