feat: ship creator journey v2 and profile updates
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App\Http\Controllers\Api;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Artwork;
|
||||
use App\Services\ArtworkStatsService;
|
||||
use App\Services\Profile\CreatorJourneyService;
|
||||
use App\Services\ThumbnailPresenter;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -31,7 +32,10 @@ use Illuminate\Support\Str;
|
||||
*/
|
||||
final class ArtworkDownloadController extends Controller
|
||||
{
|
||||
public function __construct(private readonly ArtworkStatsService $stats) {}
|
||||
public function __construct(
|
||||
private readonly ArtworkStatsService $stats,
|
||||
private readonly CreatorJourneyService $journeys,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request, int $id): JsonResponse
|
||||
{
|
||||
@@ -48,13 +52,15 @@ final class ArtworkDownloadController extends Controller
|
||||
// Record the download event — non-blocking, errors are swallowed.
|
||||
$this->recordDownload($request, $artwork);
|
||||
|
||||
// Increment counters — deferred via Redis when available.
|
||||
// Increment counters immediately so Studio stats stay fresh.
|
||||
try {
|
||||
$this->stats->incrementDownloads((int) $artwork->id, 1, defer: true);
|
||||
$this->stats->incrementDownloads((int) $artwork->id, 1, defer: false);
|
||||
} catch (\Throwable) {
|
||||
// Stats failure must never interrupt the download.
|
||||
}
|
||||
|
||||
$this->journeys->requestRebuild((int) $artwork->user_id);
|
||||
|
||||
// Resolve the highest-resolution download URL available.
|
||||
$url = $this->resolveDownloadUrl($artwork);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user