Wire admin studio SSR and search infrastructure
This commit is contained in:
@@ -428,3 +428,38 @@ it('produces cosine-normalized weights in pair builder', function () {
|
||||
// S_beh = 2 / sqrt(2 * 2) = 2 / 2 = 1.0
|
||||
expect($pair->weight)->toBe(1.0);
|
||||
});
|
||||
|
||||
it('accumulates pair weights across small user chunks and rebuilds cleanly on rerun', function () {
|
||||
$userA = User::factory()->create();
|
||||
$userB = User::factory()->create();
|
||||
$art1 = createPublicArtwork();
|
||||
$art2 = createPublicArtwork();
|
||||
|
||||
DB::table('artwork_favourites')->insert([
|
||||
['user_id' => $userA->id, 'artwork_id' => $art1->id, 'created_at' => now()->subMinute(), 'updated_at' => now()->subMinute()],
|
||||
['user_id' => $userA->id, 'artwork_id' => $art2->id, 'created_at' => now()->subMinute(), 'updated_at' => now()->subMinute()],
|
||||
['user_id' => $userB->id, 'artwork_id' => $art1->id, 'created_at' => now(), 'updated_at' => now()],
|
||||
['user_id' => $userB->id, 'artwork_id' => $art2->id, 'created_at' => now(), 'updated_at' => now()],
|
||||
]);
|
||||
|
||||
$job = new RecBuildItemPairsFromFavouritesJob(1);
|
||||
$job->handle();
|
||||
|
||||
$pair = RecItemPair::query()
|
||||
->where('a_artwork_id', min($art1->id, $art2->id))
|
||||
->where('b_artwork_id', max($art1->id, $art2->id))
|
||||
->first();
|
||||
|
||||
expect($pair)->not->toBeNull();
|
||||
expect($pair?->weight)->toBe(1.0);
|
||||
|
||||
$job->handle();
|
||||
|
||||
$rebuiltPair = RecItemPair::query()
|
||||
->where('a_artwork_id', min($art1->id, $art2->id))
|
||||
->where('b_artwork_id', max($art1->id, $art2->id))
|
||||
->first();
|
||||
|
||||
expect($rebuiltPair)->not->toBeNull();
|
||||
expect($rebuiltPair?->weight)->toBe(1.0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user