Add data export retry and cancel controls
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-02 22:50:07 +01:00
parent 66bf9e4a8c
commit 75d862748b
8 changed files with 222 additions and 2 deletions

View File

@@ -19,6 +19,8 @@ class DataExport extends Model
public const STATUS_FAILED = 'failed';
public const STATUS_CANCELED = 'canceled';
protected $fillable = [
'user_id',
'tenant_id',
@@ -58,6 +60,38 @@ class DataExport extends Model
return $this->status === self::STATUS_READY;
}
public function canRetry(): bool
{
return in_array($this->status, [self::STATUS_FAILED, self::STATUS_CANCELED], true);
}
public function canCancel(): bool
{
return in_array($this->status, [self::STATUS_PENDING, self::STATUS_PROCESSING], true);
}
public function resetForRetry(): void
{
$this->update([
'status' => self::STATUS_PENDING,
'error_message' => null,
'path' => null,
'size_bytes' => null,
'expires_at' => null,
]);
}
public function markCanceled(?string $reason = null): void
{
$this->update([
'status' => self::STATUS_CANCELED,
'error_message' => $reason ?: 'Canceled by superadmin.',
'path' => null,
'size_bytes' => null,
'expires_at' => null,
]);
}
public function hasExpired(): bool
{
return $this->expires_at !== null && $this->expires_at->isPast();