Allow artworks to have one primary category and extra secondaries.
Keep artwork_category as membership, store a deterministic primary_category_id, and let upload plus studio pick up to five additional same-type categories without changing canonical URLs.
This commit is contained in:
@@ -49,8 +49,9 @@ final class StudioAiCategoryMapper
|
||||
$selectedCategory,
|
||||
$this->confidenceForModel($categoryScores, $selectedCategory->id),
|
||||
$categoryScores
|
||||
->reject(fn (array $row): bool => (int) $row['model']->id === (int) $selectedCategory->id)
|
||||
->take(3)
|
||||
->reject(fn (array $row): bool => (int) $row['model']->id === (int) $selectedCategory->id
|
||||
|| (int) $row['model']->content_type_id !== (int) $selectedCategory->content_type_id)
|
||||
->take(max(0, (int) config('categories.max_secondary_categories', 5)))
|
||||
->map(fn (array $row): array => $this->serializeCategory($row['model'], $row['confidence']))
|
||||
->all()
|
||||
) : null,
|
||||
@@ -245,6 +246,7 @@ final class StudioAiCategoryMapper
|
||||
'root_category_id' => (int) $rootCategory->id,
|
||||
'sub_category_id' => $category->parent_id ? (int) $category->id : null,
|
||||
'alternatives' => array_values($alternatives),
|
||||
'secondary_categories' => array_values($alternatives),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user