Skip to content

Commit

Permalink
Merge branch 'main' into feat/selection-pop-up
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Nov 22, 2024
2 parents 48d3b02 + 59677db commit 4861e37
Show file tree
Hide file tree
Showing 32 changed files with 778 additions and 461 deletions.
130 changes: 124 additions & 6 deletions _ide_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* A helper file for Laravel, to provide autocomplete information to your IDE
* Generated for Laravel 11.31.0.
* Generated for Laravel 11.33.2.
*
* This file should not be included in your code, only analyzed by your IDE!
*
Expand Down Expand Up @@ -4494,8 +4494,8 @@
/**
* Get many configuration values.
*
* @param array $keys
* @return array
* @param array<string|int,mixed> $keys
* @return array<string,mixed>
* @static
*/ public static function getMany($keys)
{
Expand Down Expand Up @@ -6000,7 +6000,7 @@
* @param string $query
* @param array $bindings
* @param bool $useReadPdo
* @return \Generator
* @return \Generator<int, \stdClass>
* @static
*/ public static function cursor($query, $bindings = [], $useReadPdo = true)
{ //Method inherited from \Illuminate\Database\Connection
Expand Down Expand Up @@ -8324,6 +8324,16 @@
*/ public static function response($body = null, $status = 200, $headers = [])
{
return \Illuminate\Http\Client\Factory::response($body, $status, $headers);
}
/**
* Create a new connection exception for use during stubbing.
*
* @param string|null $message
* @return \GuzzleHttp\Promise\PromiseInterface
* @static
*/ public static function failedConnection($message = null)
{
return \Illuminate\Http\Client\Factory::failedConnection($message);
}
/**
* Get an invokable object that returns a sequence of responses in order for use during stubbing.
Expand Down Expand Up @@ -8405,7 +8415,7 @@
* Record a request response pair.
*
* @param \Illuminate\Http\Client\Request $request
* @param \Illuminate\Http\Client\Response $response
* @param \Illuminate\Http\Client\Response|null $response
* @return void
* @static
*/ public static function recordRequestResponsePair($request, $response)
Expand Down Expand Up @@ -13096,6 +13106,19 @@
{
/** @var \Illuminate\Http\Request $instance */
return $instance->enum($key, $enumClass);
}
/**
* Retrieve input from the request as an array of enums.
*
* @template TEnum
* @param string $key
* @param \Illuminate\Http\class-string<TEnum> $enumClass
* @return \Illuminate\Http\TEnum[]
* @static
*/ public static function enums($key, $enumClass)
{
/** @var \Illuminate\Http\Request $instance */
return $instance->enums($key, $enumClass);
}
/**
* Retrieve input from the request as a collection.
Expand Down Expand Up @@ -13497,7 +13520,7 @@
/**
* Create a new redirect response to a named route.
*
* @param string $route
* @param \BackedEnum|string $route
* @param mixed $parameters
* @param int $status
* @param array $headers
Expand Down Expand Up @@ -14521,6 +14544,66 @@
/**
*
*
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes withoutOverlapping(int $expiresAt = 1440)
* @method static void mergeAttributes(\Illuminate\Console\Scheduling\Event $event)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes user(string $user)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes environments(array|mixed $environments)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes evenInMaintenanceMode()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes onOneServer()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes runInBackground()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes when(\Closure|bool $callback)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes skip(\Closure|bool $callback)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes cron(string $expression)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes between(string $startTime, string $endTime)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes unlessBetween(string $startTime, string $endTime)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everySecond()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyTwoSeconds()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyFiveSeconds()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyTenSeconds()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyFifteenSeconds()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyTwentySeconds()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyThirtySeconds()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyMinute()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyTwoMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyThreeMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyFourMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyFiveMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyTenMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyFifteenMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyThirtyMinutes()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes hourly()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes hourlyAt(array|string|int $offset)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyOddHour(array|string|int $offset = 0)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyTwoHours(array|string|int $offset = 0)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyThreeHours(array|string|int $offset = 0)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everyFourHours(array|string|int $offset = 0)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes everySixHours(array|string|int $offset = 0)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes daily()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes at(string $time)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes dailyAt(string $time)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes twiceDaily(int $first = 1, int $second = 13)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes twiceDailyAt(int $first = 1, int $second = 13, int $offset = 0)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes weekdays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes weekends()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes mondays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes tuesdays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes wednesdays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes thursdays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes fridays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes saturdays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes sundays()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes weekly()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes weeklyOn(array|mixed $dayOfWeek, string $time = '0:0')
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes monthly()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes monthlyOn(int $dayOfMonth = 1, string $time = '0:0')
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes twiceMonthly(int $first = 1, int $second = 16, string $time = '0:0')
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes lastDayOfMonth(string $time = '0:0')
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes quarterly()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes quarterlyOn(int $dayOfQuarter = 1, string $time = '0:0')
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes yearly()
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes yearlyOn(int $month = 1, int|string $dayOfMonth = 1, string $time = '0:0')
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes days(array|mixed $days)
* @method static \Illuminate\Console\Scheduling\PendingEventAttributes timezone(\DateTimeZone|string $timezone)
* @see \Illuminate\Console\Scheduling\Schedule
*/ class Schedule {
/**
Expand Down Expand Up @@ -14571,6 +14654,17 @@
{
/** @var \Illuminate\Console\Scheduling\Schedule $instance */
return $instance->exec($command, $parameters);
}
/**
* Create new schedule group.
*
* @param \Illuminate\Console\Scheduling\Event $event
* @return void
* @static
*/ public static function group($events)
{
/** @var \Illuminate\Console\Scheduling\Schedule $instance */
$instance->group($events);
}
/**
* Compile array input for a command.
Expand Down Expand Up @@ -14670,6 +14764,19 @@
*/ public static function flushMacros()
{
\Illuminate\Console\Scheduling\Schedule::flushMacros();
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @return mixed
* @throws \BadMethodCallException
* @static
*/ public static function macroCall($method, $parameters)
{
/** @var \Illuminate\Console\Scheduling\Schedule $instance */
return $instance->macroCall($method, $parameters);
}
}
/**
Expand Down Expand Up @@ -23061,6 +23168,17 @@ class Eloquent extends \Illuminate\Database\Eloquent\Model {
{
/** @var \Illuminate\Database\Eloquent\Builder $instance */
return $instance->create($attributes);
}
/**
* Save a new model and return the instance without raising model events.
*
* @param array $attributes
* @return \Illuminate\Database\Eloquent\TModel
* @static
*/ public static function createQuietly($attributes = [])
{
/** @var \Illuminate\Database\Eloquent\Builder $instance */
return $instance->createQuietly($attributes);
}
/**
* Save a new model and return the instance. Allow mass-assignment.
Expand Down
39 changes: 39 additions & 0 deletions app/Actions/CheckForScheduledSpeedtests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Actions;

use App\Actions\Ookla\StartSpeedtest;
use Cron\CronExpression;
use Lorisleiva\Actions\Concerns\AsAction;

class CheckForScheduledSpeedtests
{
use AsAction;

public function handle(): void
{
$schedule = config('speedtest.schedule');

if (blank($schedule) || $schedule === false) {
return;
}

StartSpeedtest::runIf(
$this->isSpeedtestDue(schedule: $schedule),
scheduled: true,
);
}

/**
* Assess if a speedtest is due to run based on the schedule.
*/
private function isSpeedtestDue(string $schedule): bool
{
$cron = new CronExpression($schedule);

return $cron->isDue(
currentTime: now(),
timeZone: config('app.display_timezone')
);
}
}
34 changes: 34 additions & 0 deletions app/Actions/GetExternalIpAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Actions;

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Lorisleiva\Actions\Concerns\AsAction;

class GetExternalIpAddress
{
use AsAction;

public function handle(): bool|string
{
$externalIp = Cache::remember('external_ip', 30, function (): bool|string {
$response = Http::retry(3, 100)
->get('https://icanhazip.com/');

if ($response->failed()) {
$message = sprintf('Failed to fetch external IP address, %d', $response->status());

Log::warning($message);

return false;
}

return Str::trim($response->body());
});

return $externalIp;
}
}
33 changes: 33 additions & 0 deletions app/Actions/Ookla/SelectSpeedtestServer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Actions\Ookla;

use Illuminate\Support\Arr;
use Lorisleiva\Actions\Concerns\AsAction;

class SelectSpeedtestServer
{
use AsAction;

public function handle(): string
{
$servers = config('speedtest.servers');

if (blank($servers)) {
return '';
}

$servers = array_filter(
array_map(
'trim',
explode(',', $servers),
),
);

if (count($servers) < 1) {
return '';
}

return Arr::random($servers);
}
}
38 changes: 38 additions & 0 deletions app/Actions/Ookla/StartSpeedtest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Actions\Ookla;

use App\Enums\ResultService;
use App\Enums\ResultStatus;
use App\Events\SpeedtestStarted;
use App\Jobs\Ookla\ProcessSpeedtestBatch;
use App\Models\Result;
use Lorisleiva\Actions\Concerns\AsAction;

class StartSpeedtest
{
use AsAction;

public function handle(bool $scheduled = false): void
{
$result = Result::create([
'service' => ResultService::Ookla,
'status' => ResultStatus::Started,
'scheduled' => $scheduled,
]);

$serverId = SelectSpeedtestServer::run();

if (! blank($serverId)) {
$result->update([
'data->server->id' => $serverId,
]);
}

ProcessSpeedtestBatch::dispatch(
result: $result,
);

SpeedtestStarted::dispatch($result);
}
}
27 changes: 0 additions & 27 deletions app/Actions/Speedtests/RunOoklaSpeedtest.php

This file was deleted.

Loading

0 comments on commit 4861e37

Please sign in to comment.