fix
This commit is contained in:
@@ -482,10 +482,14 @@ private function similarMedia(Media $media, int $limit = 5)
|
|||||||
'tags as tag_matches' => fn ($t) => $t->whereIn('tags.id', $tagIds ?: [0]),
|
'tags as tag_matches' => fn ($t) => $t->whereIn('tags.id', $tagIds ?: [0]),
|
||||||
])
|
])
|
||||||
->with(['image', 'detailImage', 'categories', 'subCategories', 'tags'])
|
->with(['image', 'detailImage', 'categories', 'subCategories', 'tags'])
|
||||||
->orderByRaw('(category_matches + subcategory_matches + tag_matches) desc')
|
// Pull a recent candidate pool (portable; Postgres can't ORDER BY alias
|
||||||
|
// expressions), then rank by overlap in PHP.
|
||||||
->orderByDesc('created_at')
|
->orderByDesc('created_at')
|
||||||
->limit($limit)
|
->limit(60)
|
||||||
->get();
|
->get()
|
||||||
|
->sortByDesc(fn ($m) => $m->category_matches + $m->subcategory_matches + $m->tag_matches)
|
||||||
|
->take($limit)
|
||||||
|
->values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rate(Request $request, $mediaId)
|
public function rate(Request $request, $mediaId)
|
||||||
|
|||||||
Reference in New Issue
Block a user