feat: add tag discovery analytics and reporting
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Services\ArtworkSearchIndexer;
|
||||
use App\Services\ArtworkVersioningService;
|
||||
use App\Services\Studio\StudioArtworkQueryService;
|
||||
use App\Services\Studio\StudioBulkActionService;
|
||||
use App\Services\Tags\TagDiscoveryService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -27,6 +28,7 @@ final class StudioArtworksApiController extends Controller
|
||||
private readonly StudioBulkActionService $bulkService,
|
||||
private readonly ArtworkVersioningService $versioningService,
|
||||
private readonly ArtworkSearchIndexer $searchIndexer,
|
||||
private readonly TagDiscoveryService $tagDiscoveryService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -264,18 +266,13 @@ final class StudioArtworksApiController extends Controller
|
||||
|
||||
/**
|
||||
* GET /api/studio/tags/search?q=...
|
||||
* Search active tags by name for the bulk tag picker.
|
||||
* Search active tags for studio pickers, with empty-query fallback to popular tags.
|
||||
*/
|
||||
public function searchTags(Request $request): JsonResponse
|
||||
{
|
||||
$query = trim((string) $request->input('q'));
|
||||
|
||||
$tags = \App\Models\Tag::query()
|
||||
->where('is_active', true)
|
||||
->when($query !== '', fn ($q) => $q->where('name', 'LIKE', "%{$query}%"))
|
||||
->orderByDesc('usage_count')
|
||||
->limit(30)
|
||||
->get(['id', 'name', 'slug', 'usage_count']);
|
||||
$tags = $this->tagDiscoveryService->searchSuggestions($query, 30);
|
||||
|
||||
return response()->json($tags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user