instances added god may help
This commit is contained in:
@@ -7,7 +7,7 @@ use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ScheduledJobRepository
|
||||
{
|
||||
public static function create(array $data): int|false
|
||||
public function create(array $data): int|false
|
||||
{
|
||||
$id = DB::insert(
|
||||
'insert into scheduled_jobs (
|
||||
@@ -30,26 +30,26 @@ class ScheduledJobRepository
|
||||
return $id ? (int) $id : false;
|
||||
}
|
||||
|
||||
public static function find(int $id): ?array
|
||||
public function find(int $id): ?array
|
||||
{
|
||||
if ($id <= 0) {
|
||||
return null;
|
||||
}
|
||||
$row = DB::selectOne('select * from scheduled_jobs where id = ? limit 1', (string) $id);
|
||||
return self::normalizeRow($row);
|
||||
return $this->normalizeRow($row);
|
||||
}
|
||||
|
||||
public static function findByKey(string $jobKey): ?array
|
||||
public function findByKey(string $jobKey): ?array
|
||||
{
|
||||
$jobKey = trim($jobKey);
|
||||
if ($jobKey === '') {
|
||||
return null;
|
||||
}
|
||||
$row = DB::selectOne('select * from scheduled_jobs where job_key = ? limit 1', $jobKey);
|
||||
return self::normalizeRow($row);
|
||||
return $this->normalizeRow($row);
|
||||
}
|
||||
|
||||
public static function listPaged(array $filters): array
|
||||
public function listPaged(array $filters): array
|
||||
{
|
||||
$search = trim((string) ($filters['search'] ?? ''));
|
||||
$enabled = trim((string) ($filters['enabled'] ?? ''));
|
||||
@@ -92,7 +92,7 @@ class ScheduledJobRepository
|
||||
$normalized = [];
|
||||
if (is_array($rows)) {
|
||||
foreach ($rows as $row) {
|
||||
$item = self::normalizeRow($row);
|
||||
$item = $this->normalizeRow($row);
|
||||
if ($item !== null) {
|
||||
$normalized[] = $item;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class ScheduledJobRepository
|
||||
];
|
||||
}
|
||||
|
||||
public static function listDueJobs(string $nowUtc, int $limit = 20): array
|
||||
public function listDueJobs(string $nowUtc, int $limit = 20): array
|
||||
{
|
||||
$limit = max(1, min(200, $limit));
|
||||
$rows = DB::select(
|
||||
@@ -122,7 +122,7 @@ class ScheduledJobRepository
|
||||
$normalized = [];
|
||||
if (is_array($rows)) {
|
||||
foreach ($rows as $row) {
|
||||
$item = self::normalizeRow($row);
|
||||
$item = $this->normalizeRow($row);
|
||||
if ($item !== null) {
|
||||
$normalized[] = $item;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ class ScheduledJobRepository
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
public static function updateJobMeta(int $id, array $data): bool
|
||||
public function updateJobMeta(int $id, array $data): bool
|
||||
{
|
||||
if ($id <= 0) {
|
||||
return false;
|
||||
@@ -176,7 +176,7 @@ class ScheduledJobRepository
|
||||
* Returns true only when the UPDATE affected a row, i.e. the job was successfully
|
||||
* claimed by this runner. Returns false if the job is already running (not stale).
|
||||
*/
|
||||
public static function markRunning(int $id, string $startedAtUtc): bool
|
||||
public function markRunning(int $id, string $startedAtUtc): bool
|
||||
{
|
||||
if ($id <= 0) {
|
||||
return false;
|
||||
@@ -206,7 +206,7 @@ class ScheduledJobRepository
|
||||
return (int) $updated > 0;
|
||||
}
|
||||
|
||||
public static function finishRun(
|
||||
public function finishRun(
|
||||
int $id,
|
||||
string $status,
|
||||
string $startedAtUtc,
|
||||
@@ -238,7 +238,7 @@ class ScheduledJobRepository
|
||||
return $updated !== false;
|
||||
}
|
||||
|
||||
private static function normalizeRow(mixed $row): ?array
|
||||
private function normalizeRow(mixed $row): ?array
|
||||
{
|
||||
if (!is_array($row)) {
|
||||
return null;
|
||||
|
||||
@@ -7,7 +7,7 @@ use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ScheduledJobRunRepository
|
||||
{
|
||||
public static function create(array $data): int|false
|
||||
public function create(array $data): int|false
|
||||
{
|
||||
$id = DB::insert(
|
||||
'insert into scheduled_job_runs (
|
||||
@@ -30,7 +30,7 @@ class ScheduledJobRunRepository
|
||||
return $id ? (int) $id : false;
|
||||
}
|
||||
|
||||
public static function listPagedByJobId(int $jobId, array $filters): array
|
||||
public function listPagedByJobId(int $jobId, array $filters): array
|
||||
{
|
||||
if ($jobId <= 0) {
|
||||
return ['total' => 0, 'rows' => []];
|
||||
@@ -97,7 +97,7 @@ class ScheduledJobRunRepository
|
||||
$normalized = [];
|
||||
if (is_array($rows)) {
|
||||
foreach ($rows as $row) {
|
||||
$item = self::normalizeRow($row);
|
||||
$item = $this->normalizeRow($row);
|
||||
if ($item !== null) {
|
||||
$normalized[] = $item;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class ScheduledJobRunRepository
|
||||
return ['total' => $total, 'rows' => $normalized];
|
||||
}
|
||||
|
||||
public static function purgeOlderThanDays(int $days): int
|
||||
public function purgeOlderThanDays(int $days): int
|
||||
{
|
||||
if ($days <= 0) {
|
||||
return 0;
|
||||
@@ -119,7 +119,7 @@ class ScheduledJobRunRepository
|
||||
return is_int($deleted) ? $deleted : 0;
|
||||
}
|
||||
|
||||
private static function normalizeRow(mixed $row): ?array
|
||||
private function normalizeRow(mixed $row): ?array
|
||||
{
|
||||
if (!is_array($row)) {
|
||||
return null;
|
||||
|
||||
@@ -6,7 +6,7 @@ use MintyPHP\DB;
|
||||
|
||||
class SchedulerRuntimeRepository
|
||||
{
|
||||
public static function touchHeartbeat(string $result, ?string $errorCode = null, ?string $heartbeatAtUtc = null): bool
|
||||
public function touchHeartbeat(string $result, ?string $errorCode = null, ?string $heartbeatAtUtc = null): bool
|
||||
{
|
||||
$heartbeatAtUtc = trim((string) ($heartbeatAtUtc ?? ''));
|
||||
if ($heartbeatAtUtc === '') {
|
||||
@@ -17,7 +17,7 @@ class SchedulerRuntimeRepository
|
||||
if ($result === '') {
|
||||
$result = 'ok';
|
||||
}
|
||||
$errorCode = self::nullableTrim($errorCode);
|
||||
$errorCode = $this->nullableTrim($errorCode);
|
||||
|
||||
$updated = DB::update(
|
||||
'insert into scheduler_runtime_status (id, last_heartbeat_at, last_result, last_error_code) ' .
|
||||
@@ -34,7 +34,7 @@ class SchedulerRuntimeRepository
|
||||
return $updated !== false;
|
||||
}
|
||||
|
||||
public static function findStatus(): ?array
|
||||
public function findStatus(): ?array
|
||||
{
|
||||
$row = DB::selectOne('select * from scheduler_runtime_status where id = 1 limit 1');
|
||||
if (!is_array($row)) {
|
||||
@@ -44,7 +44,7 @@ class SchedulerRuntimeRepository
|
||||
return is_array($item) ? $item : null;
|
||||
}
|
||||
|
||||
private static function nullableTrim(?string $value): ?string
|
||||
private function nullableTrim(?string $value): ?string
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
return $value !== '' ? $value : null;
|
||||
|
||||
Reference in New Issue
Block a user