Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| ImportJobModel | |
100.00% |
16 / 16 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| casts | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
| newFactory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| creator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| file | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| errors | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| logs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Importing\Infrastructure\Persistence\Eloquent; |
| 6 | |
| 7 | use App\Models\User; |
| 8 | use Database\Factories\ImportJobFactory; |
| 9 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 10 | use Illuminate\Database\Eloquent\Model; |
| 11 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 12 | use Illuminate\Database\Eloquent\Relations\HasMany; |
| 13 | use Illuminate\Database\Eloquent\Relations\HasOne; |
| 14 | use ImovelZapAi\Importing\Domain\Enums\ImportJobStatus; |
| 15 | use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\BelongsToTenant; |
| 16 | use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey; |
| 17 | |
| 18 | /** |
| 19 | * @property string $id |
| 20 | * @property string $tenant_id |
| 21 | * @property string|null $created_by |
| 22 | * @property ImportJobStatus|string $status |
| 23 | * @property array<string, mixed>|null $mapping |
| 24 | * @property array<string, mixed>|null $preview_summary |
| 25 | * @property array<string, mixed>|null $report_summary |
| 26 | */ |
| 27 | class ImportJobModel extends Model |
| 28 | { |
| 29 | use BelongsToTenant; |
| 30 | use HasFactory; |
| 31 | use HasUuidPrimaryKey; |
| 32 | |
| 33 | protected $table = 'import_jobs'; |
| 34 | |
| 35 | protected $fillable = [ |
| 36 | 'tenant_id', |
| 37 | 'created_by', |
| 38 | 'status', |
| 39 | 'format', |
| 40 | 'idempotency_key', |
| 41 | 'total_listings', |
| 42 | 'valid_listings', |
| 43 | 'error_listings', |
| 44 | 'warning_listings', |
| 45 | 'imported_count', |
| 46 | 'updated_count', |
| 47 | 'unchanged_count', |
| 48 | 'ignored_count', |
| 49 | 'failed_count', |
| 50 | 'photos_imported', |
| 51 | 'checkpoint_index', |
| 52 | 'progress_current', |
| 53 | 'progress_total', |
| 54 | 'mapping', |
| 55 | 'preview_summary', |
| 56 | 'report_summary', |
| 57 | 'failure_message', |
| 58 | 'analyzing_started_at', |
| 59 | 'preview_ready_at', |
| 60 | 'queued_at', |
| 61 | 'processing_started_at', |
| 62 | 'completed_at', |
| 63 | ]; |
| 64 | |
| 65 | protected function casts(): array |
| 66 | { |
| 67 | return [ |
| 68 | 'status' => ImportJobStatus::class, |
| 69 | 'mapping' => 'array', |
| 70 | 'preview_summary' => 'array', |
| 71 | 'report_summary' => 'array', |
| 72 | 'analyzing_started_at' => 'datetime', |
| 73 | 'preview_ready_at' => 'datetime', |
| 74 | 'queued_at' => 'datetime', |
| 75 | 'processing_started_at' => 'datetime', |
| 76 | 'completed_at' => 'datetime', |
| 77 | ]; |
| 78 | } |
| 79 | |
| 80 | protected static function newFactory(): ImportJobFactory |
| 81 | { |
| 82 | return ImportJobFactory::new(); |
| 83 | } |
| 84 | |
| 85 | public function creator(): BelongsTo |
| 86 | { |
| 87 | return $this->belongsTo(User::class, 'created_by'); |
| 88 | } |
| 89 | |
| 90 | public function file(): HasOne |
| 91 | { |
| 92 | return $this->hasOne(ImportFileModel::class, 'import_job_id'); |
| 93 | } |
| 94 | |
| 95 | public function errors(): HasMany |
| 96 | { |
| 97 | return $this->hasMany(ImportErrorModel::class, 'import_job_id'); |
| 98 | } |
| 99 | |
| 100 | public function logs(): HasMany |
| 101 | { |
| 102 | return $this->hasMany(ImportLogModel::class, 'import_job_id'); |
| 103 | } |
| 104 | } |