feat: add reusable gallery carousel and ranking feed infrastructure

This commit is contained in:
2026-02-28 07:56:25 +01:00
parent 67ef79766c
commit 6536d4ae78
36 changed files with 3177 additions and 373 deletions

View File

@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Materialised ranking score table.
*
* Stores three pre-computed scores per artwork:
* score_trending time-decayed engagement (HL=72h)
* score_new_hot short novelty boost (HL=36h, first 48h emphasis)
* score_best slow-decay evergreen (HL=720h)
*
* Rebuilt hourly by RankComputeArtworkScoresJob.
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('rank_artwork_scores', function (Blueprint $table): void {
$table->unsignedBigInteger('artwork_id')->primary();
$table->foreign('artwork_id')->references('id')->on('artworks')->cascadeOnDelete();
$table->double('score_trending', 10, 6)->default(0)->index();
$table->double('score_new_hot', 10, 6)->default(0)->index();
$table->double('score_best', 10, 6)->default(0)->index();
$table->string('model_version', 32)->default('rank_v1')->index();
$table->timestamp('computed_at')->nullable()->index();
});
}
public function down(): void
{
Schema::dropIfExists('rank_artwork_scores');
}
};

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Ranked list cache table.
*
* Stores ordered artwork_id JSON arrays for each feed surface:
* scope_type : global | category | content_type
* scope_id : 0 for global, foreign-key id for category / content_type
* list_type : trending | new_hot | best
*
* Rebuilt hourly by RankBuildListsJob.
* scope_id uses 0 as sentinel for "global" (avoids nullable unique-key pitfalls in MySQL).
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('rank_lists', function (Blueprint $table): void {
$table->id();
$table->string('scope_type', 32)->index(); // global | category | content_type
$table->unsignedBigInteger('scope_id')->default(0)->index(); // 0 = global
$table->string('list_type', 32)->index(); // trending | new_hot | best
$table->string('model_version', 32)->default('rank_v1');
$table->json('artwork_ids'); // ordered list of ids
$table->timestamp('computed_at')->nullable();
$table->unique(
['scope_type', 'scope_id', 'list_type', 'model_version'],
'rank_lists_scope_unique'
);
});
}
public function down(): void
{
Schema::dropIfExists('rank_lists');
}
};