Studio: make grid checkbox rectangular and commit table changes

This commit is contained in:
2026-03-01 08:43:48 +01:00
parent 211dc58884
commit e3ca845a6d
89 changed files with 7323 additions and 475 deletions

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('artwork_metric_snapshots_hourly', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('artwork_id');
$table->dateTime('bucket_hour')->comment('Hour-precision bucket, e.g. 2026-02-28 14:00:00');
$table->unsignedBigInteger('views_count')->default(0);
$table->unsignedBigInteger('downloads_count')->default(0);
$table->unsignedBigInteger('favourites_count')->default(0);
$table->unsignedBigInteger('comments_count')->default(0);
$table->unsignedBigInteger('shares_count')->default(0);
$table->timestamp('created_at')->useCurrent();
$table->unique(['artwork_id', 'bucket_hour'], 'uq_artwork_bucket');
$table->index('bucket_hour', 'idx_bucket_hour');
$table->index(['artwork_id', 'bucket_hour'], 'idx_artwork_bucket');
$table->foreign('artwork_id')
->references('id')
->on('artworks')
->cascadeOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('artwork_metric_snapshots_hourly');
}
};

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('artwork_stats', function (Blueprint $table) {
$table->double('heat_score')->default(0)->after('engagement_velocity');
$table->timestamp('heat_score_updated_at')->nullable()->after('heat_score');
$table->unsignedInteger('views_1h')->default(0)->after('heat_score_updated_at');
$table->unsignedInteger('favourites_1h')->default(0)->after('views_1h');
$table->unsignedInteger('comments_1h')->default(0)->after('favourites_1h');
$table->unsignedInteger('shares_1h')->default(0)->after('comments_1h');
$table->unsignedInteger('downloads_1h')->default(0)->after('shares_1h');
$table->index('heat_score', 'idx_artwork_stats_heat_score');
});
}
public function down(): void
{
Schema::table('artwork_stats', function (Blueprint $table) {
$table->dropIndex('idx_artwork_stats_heat_score');
$table->dropColumn([
'heat_score',
'heat_score_updated_at',
'views_1h',
'favourites_1h',
'comments_1h',
'shares_1h',
'downloads_1h',
]);
});
}
};

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('rec_artwork_recs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('artwork_id');
$table->string('rec_type', 40); // similar_hybrid, similar_visual, similar_tags, similar_behavior
$table->json('recs'); // ordered array of artwork_ids
$table->string('model_version', 30)->default('sim_v1');
$table->dateTime('computed_at');
$table->timestamps();
$table->unique(['artwork_id', 'rec_type', 'model_version']);
$table->index(['artwork_id', 'rec_type']);
});
}
public function down(): void
{
Schema::dropIfExists('rec_artwork_recs');
}
};

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('rec_item_pairs', function (Blueprint $table) {
$table->unsignedBigInteger('a_artwork_id');
$table->unsignedBigInteger('b_artwork_id');
$table->double('weight')->default(0);
$table->dateTime('updated_at');
$table->unique(['a_artwork_id', 'b_artwork_id']);
$table->index(['a_artwork_id', 'weight']);
$table->index('b_artwork_id');
});
}
public function down(): void
{
Schema::dropIfExists('rec_item_pairs');
}
};

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('rec_events', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->nullable();
$table->string('session_id', 80)->nullable();
$table->string('event_type', 20); // view, favourite, download
$table->unsignedBigInteger('artwork_id');
$table->timestamp('created_at')->useCurrent();
$table->index(['artwork_id', 'created_at']);
$table->index(['user_id', 'created_at']);
$table->index(['session_id', 'created_at']);
});
}
public function down(): void
{
Schema::dropIfExists('rec_events');
}
};