7 - Add language column to pages for crawler-detected language
This commit is contained in:
parent
43837a99db
commit
b1b7adeacd
3 changed files with 23 additions and 0 deletions
|
|
@ -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',
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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 = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue