41 lines
968 B
PHP
41 lines
968 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\OpsUx;
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
|
|
final class ActiveRuns
|
|
{
|
|
public static function existForTenant(Tenant $tenant): bool
|
|
{
|
|
return self::existForTenantId((int) $tenant->getKey());
|
|
}
|
|
|
|
public static function existForTenantId(?int $tenantId): bool
|
|
{
|
|
if (! is_int($tenantId) || $tenantId <= 0) {
|
|
return false;
|
|
}
|
|
|
|
return OperationRun::query()
|
|
->where('tenant_id', $tenantId)
|
|
->healthyActive()
|
|
->exists();
|
|
}
|
|
|
|
public static function pollingIntervalForTenant(?Tenant $tenant): ?string
|
|
{
|
|
return $tenant instanceof Tenant
|
|
? self::pollingIntervalForTenantId((int) $tenant->getKey())
|
|
: null;
|
|
}
|
|
|
|
public static function pollingIntervalForTenantId(?int $tenantId): ?string
|
|
{
|
|
return self::existForTenantId($tenantId) ? '10s' : null;
|
|
}
|
|
}
|