7 - Add language column to pages for crawler-detected language

This commit is contained in:
myrmidex 2026-04-26 12:53:21 +02:00
parent 43837a99db
commit b1b7adeacd
3 changed files with 23 additions and 0 deletions

View file

@ -20,6 +20,7 @@ class Page extends Model
protected $fillable = [ protected $fillable = [
'url', 'url',
'status', 'status',
'language',
'title', 'title',
'instance_id', 'instance_id',
'posted_at', 'posted_at',

View file

@ -15,6 +15,7 @@ public function up(): void
$table->id(); $table->id();
$table->text('url')->unique(); $table->text('url')->unique();
$table->string('status')->default(PageStatusEnum::Discovered->value)->index(); $table->string('status')->default(PageStatusEnum::Discovered->value)->index();
$table->string('language', 35)->nullable()->index();
$table->string('title')->nullable(); $table->string('title')->nullable();
$table->foreignId('instance_id') $table->foreignId('instance_id')
->nullable() ->nullable()

View file

@ -76,6 +76,27 @@ public function test_page_outgoing_and_incoming_links_relationships(): void
$this->assertSame($target->id, $freshSource->outgoingLinks->first()->target_page_id); $this->assertSame($target->id, $freshSource->outgoingLinks->first()->target_page_id);
} }
public function test_page_language_is_fillable_and_persists(): void
{
$page = Page::create([
'url' => 'https://example.com/crawled',
'status' => 'discovered',
'language' => 'en',
]);
$fresh = $page->fresh();
$this->assertNotNull($fresh);
$this->assertSame('en', $fresh->language);
$unset = Page::create([
'url' => 'https://example.com/no-language',
'status' => 'discovered',
]);
$this->assertNull($unset->fresh()->language);
}
public function test_page_status_is_cast_to_enum(): void public function test_page_status_is_cast_to_enum(): void
{ {
$cases = [ $cases = [