major update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MintyPHP\Service\Audit;
|
||||
|
||||
use MintyPHP\Domain\Taxonomy\ImportAuditStatus;
|
||||
use MintyPHP\Repository\Audit\ImportAuditRunRepository;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
@@ -34,7 +35,7 @@ class ImportAuditService
|
||||
$runId = $this->importAuditRunRepository->createRunning([
|
||||
'run_uuid' => RepoQuery::uuidV4(),
|
||||
'profile_key' => $profileKey,
|
||||
'status' => 'running',
|
||||
'status' => ImportAuditStatus::Running->value,
|
||||
'source_filename' => $this->normalizeSourceFilename($sourceFilename),
|
||||
'mapped_targets_csv' => $this->normalizeMappedTargetsCsv($mappedTargets),
|
||||
'user_id' => $userId > 0 ? $userId : null,
|
||||
@@ -67,13 +68,13 @@ class ImportAuditService
|
||||
$status = $this->normalizeStatus($forcedStatus);
|
||||
if ($status === null) {
|
||||
if (array_key_exists('ok', $result) && !($result['ok'] ?? false)) {
|
||||
$status = 'failed';
|
||||
$status = ImportAuditStatus::Failed->value;
|
||||
} elseif ($failedCount <= 0) {
|
||||
$status = 'success';
|
||||
$status = ImportAuditStatus::Success->value;
|
||||
} elseif ($createdCount > 0 || $skippedCount > 0) {
|
||||
$status = 'partial';
|
||||
$status = ImportAuditStatus::Partial->value;
|
||||
} else {
|
||||
$status = 'failed';
|
||||
$status = ImportAuditStatus::Failed->value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +114,11 @@ class ImportAuditService
|
||||
return $this->importAuditRunRepository->find($id);
|
||||
}
|
||||
|
||||
public function filterOptions(int $limit = 200): array
|
||||
{
|
||||
return $this->importAuditRunRepository->listFilterOptions($limit);
|
||||
}
|
||||
|
||||
public function purgeExpired(): int
|
||||
{
|
||||
return $this->importAuditRunRepository->purgeOlderThanDays(self::RETENTION_DAYS);
|
||||
@@ -156,11 +162,7 @@ class ImportAuditService
|
||||
|
||||
private function normalizeStatus(?string $status): ?string
|
||||
{
|
||||
$status = strtolower(trim((string) ($status ?? '')));
|
||||
if ($status === '') {
|
||||
return null;
|
||||
}
|
||||
return in_array($status, ['running', 'success', 'partial', 'failed'], true) ? $status : null;
|
||||
return ImportAuditStatus::tryNormalize((string) ($status ?? ''))?->value;
|
||||
}
|
||||
|
||||
private function encodeErrorCounts(array $result): ?string
|
||||
@@ -204,4 +206,3 @@ class ImportAuditService
|
||||
return is_string($encoded) ? $encoded : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user