chore: commit current workspace changes
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user