Wire admin studio SSR and search infrastructure
This commit is contained in:
@@ -11,35 +11,48 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Meilisearch\Client as MeilisearchClient;
|
||||
|
||||
/**
|
||||
* Queued job: index (or re-index) a single Artwork in Meilisearch.
|
||||
*
|
||||
* Writes directly to the Meilisearch HTTP API instead of going through
|
||||
* Scout's searchable() / MakeSearchable pipeline. This avoids the
|
||||
* after_commit double-dispatch problem and ensures the document lands
|
||||
* in the index within this job's execution, with no extra queue hop.
|
||||
*/
|
||||
class IndexArtworkJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
public int $timeout = 30;
|
||||
public int $timeout = 60;
|
||||
|
||||
public function __construct(public readonly int $artworkId) {}
|
||||
|
||||
public function handle(): void
|
||||
public function handle(MeilisearchClient $client): void
|
||||
{
|
||||
$artwork = Artwork::with(['user', 'tags', 'categories', 'stats', 'awardStat'])
|
||||
->find($this->artworkId);
|
||||
$artwork = Artwork::with([
|
||||
'user',
|
||||
'group',
|
||||
'tags',
|
||||
'categories.contentType',
|
||||
'stats',
|
||||
'awardStat',
|
||||
])->find($this->artworkId);
|
||||
|
||||
if (! $artwork) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $artwork->is_public || ! $artwork->is_approved || ! $artwork->published_at) {
|
||||
// Not public/approved — ensure it is removed from the index.
|
||||
$artwork->unsearchable();
|
||||
// Not eligible — remove from index if present.
|
||||
$client->index($artwork->searchableAs())->deleteDocument($this->artworkId);
|
||||
return;
|
||||
}
|
||||
|
||||
$artwork->searchable();
|
||||
$document = $artwork->toSearchableArray();
|
||||
$client->index($artwork->searchableAs())->addDocuments([$document]);
|
||||
}
|
||||
|
||||
public function failed(\Throwable $e): void
|
||||
|
||||
Reference in New Issue
Block a user