diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c85c071..9e0881a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -29,7 +29,10 @@ class Kernel extends ConsoleKernel }); $schedule->command('digest:send --fortnightly') - ->twiceMonthly(1,16,'13:00') + ->weeklyOn(5, '00:01') + ->when(function () { + return (time() / 604800 % 2); + }) ->onFailure(function () { Log::error("Fortnightly email digest send failed"); }); diff --git a/app/Http/Controllers/TrackerController.php b/app/Http/Controllers/TrackerController.php index a0dd212..57bd9da 100644 --- a/app/Http/Controllers/TrackerController.php +++ b/app/Http/Controllers/TrackerController.php @@ -141,7 +141,7 @@ class TrackerController extends Controller $client = new Client([ 'base_uri' => 'https://app.wayward.travel/', - 'timeout' => 20.0 + 'timeout' => 10.0 ]); $response = $client->get('trip/'.($tripId ?? config('app.current_trip_id')).'/user/zmld8ko6qy7d9j3xvq10/json'); @@ -173,60 +173,10 @@ class TrackerController extends Controller } } - $data->trip->locations = $this->decode_polyline($data->trip->route); - return $data->trip; default: // TODO: Add proper error handling. return "Something went wrong"; } } - - /* - * Decode route polyline. - * - * Source: https://github.com/dyaaj/polyline-encoder - * - * @param object $value - * @return object - */ - public function decode_polyline($value) - { - $index = 0; - $points = array(); - $lat = 0; - $lng = 0; - $id = 0; - - while ($index < strlen($value)) { - $b; - $shift = 0; - $result = 0; - do { - $b = ord(substr($value, $index++, 1)) - 63; - $result |= ($b & 0x1f) << $shift; - $shift += 5; - } while ($b > 31); - $dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1)); - $lat += $dlat; - - $shift = 0; - $result = 0; - do { - $b = ord(substr($value, $index++, 1)) - 63; - $result |= ($b & 0x1f) << $shift; - $shift += 5; - } while ($b > 31); - $dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1)); - $lng += $dlng; - - array_push($points, (object)[ - 'id' => $id++, - 'latitude' => $lat/100000, - 'longitude'=> $lng/100000 - ]); - } - - return $points; - } } diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index fb60e1d..7bfdf6b 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -63,7 +63,7 @@ var routePoints = L.polyline([ @foreach($trip->locations as $location) @if(!in_array($location->id, config('app.current_trip_ignore'))) - [{{ $location->latitude }}, {{ $location->longitude }}], // {{$location->id}} + [{{ $location->latitude }}, {{ $location->longitude }}], @endif @endforeach ], {