chore: commit current workspace changes

This commit is contained in:
2026-05-02 09:37:14 +02:00
parent 79235133f0
commit caf1464aa5
121 changed files with 485218 additions and 181663 deletions

View File

@@ -4,8 +4,11 @@ declare(strict_types=1);
use App\Jobs\IngestUserDiscoveryEventJob;
use App\Models\Artwork;
use App\Models\Category;
use App\Models\ContentType;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Queue;
uses(RefreshDatabase::class);
@@ -65,3 +68,56 @@ it('accepts session-oriented discovery events', function () {
return $job->eventType === 'dwell';
});
});
it('stores discovery event meta as json when ingesting queued events', function (): void {
$user = User::factory()->create();
$contentType = ContentType::query()->create([
'name' => 'Skins',
'slug' => 'skins',
]);
$category = Category::query()->create([
'content_type_id' => $contentType->id,
'name' => 'Audio',
'slug' => 'audio',
'is_active' => true,
]);
$artwork = Artwork::factory()->create([
'user_id' => $user->id,
]);
DB::table('artwork_category')->insert([
'artwork_id' => $artwork->id,
'category_id' => $category->id,
]);
$meta = [
'source' => 'feed',
'context' => [
'slot' => 'for-you',
'score' => 0.88,
],
];
$job = new IngestUserDiscoveryEventJob(
eventId: (string) \Illuminate\Support\Str::uuid(),
userId: $user->id,
artworkId: $artwork->id,
eventType: 'view',
algoVersion: 'clip-cosine-v2-adaptive',
occurredAt: now()->toIso8601String(),
meta: $meta,
);
$job->handle(
app(\App\Services\Recommendations\UserInterestProfileService::class),
app(\App\Services\Recommendations\SessionRecoService::class),
);
$storedMeta = DB::table('user_discovery_events')->value('meta');
expect($storedMeta)->not->toBeNull();
expect(json_decode((string) $storedMeta, true))->toBe($meta);
});