fix: enable cron daemon in Dockerfile, speed up sync interval to every 5 minutes and add opportunistic auto-sync check
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Services\MakerWorldService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MakerWorldController extends Controller
|
||||
@@ -31,6 +32,22 @@ class MakerWorldController extends Controller
|
||||
$apiCollections = [];
|
||||
|
||||
if ($tab === 'collections') {
|
||||
// Check of actieve collecties toe zijn aan synchronisatie (> 5 minuten geleden of nog nooit gesynchroniseerd)
|
||||
$dueCollections = MakerWorldCollection::where('is_active_sync', true)
|
||||
->where(function ($q) {
|
||||
$q->whereNull('last_synced_at')
|
||||
->orWhere('last_synced_at', '<=', now()->subMinutes(5));
|
||||
})
|
||||
->get();
|
||||
|
||||
foreach ($dueCollections as $dueCol) {
|
||||
try {
|
||||
$this->makerWorld->syncCollection($dueCol);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning("Auto-sync error for collection #{$dueCol->id}: {$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
if ($isAuthenticated) {
|
||||
$apiCollections = $this->makerWorld->getFavoritesCollections();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user