Skip to content

Commit 85e3f54

Browse files
shanerbaner82claude
andcommitted
Dispatch resync via queue instead of inline Livewire request
The Filament re-sync action was running PluginSyncService inline during the Livewire request, making multiple GitHub API calls that timed out in production. Now dispatches the existing SyncPlugin job via Horizon. Also removes the temporary test-sync debug route. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 09d8dd3 commit 85e3f54

2 files changed

Lines changed: 7 additions & 61 deletions

File tree

app/Filament/Resources/PluginResource/Pages/EditPlugin.php

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
use App\Enums\PluginType;
77
use App\Filament\Resources\PluginResource;
88
use App\Jobs\ReviewPluginRepository;
9+
use App\Jobs\SyncPlugin;
910
use App\Jobs\SyncPluginReleases;
1011
use App\Models\PluginLicense;
1112
use App\Models\User;
12-
use App\Services\PluginSyncService;
1313
use Filament\Actions;
1414
use Filament\Forms;
1515
use Filament\Notifications\Notification;
1616
use Filament\Resources\Pages\EditRecord;
17-
use Illuminate\Support\Facades\Log;
1817
use Illuminate\Support\HtmlString;
1918

2019
class EditPlugin extends EditRecord
@@ -231,49 +230,13 @@ protected function getHeaderActions(): array
231230
->modalHeading('Re-sync Plugin')
232231
->modalDescription(fn () => "This will re-fetch the README, composer.json, nativephp.json, license, and latest version from GitHub for '{$this->record->name}'.")
233232
->action(function (): void {
234-
Log::info('[Filament:Resync] Action triggered', [
235-
'plugin_id' => $this->record->id,
236-
'name' => $this->record->name,
237-
'repository_url' => $this->record->repository_url,
238-
]);
239-
240-
try {
241-
$syncService = app(PluginSyncService::class);
242-
$result = $syncService->sync($this->record);
243-
244-
Log::info('[Filament:Resync] Sync returned', [
245-
'plugin_id' => $this->record->id,
246-
'result' => $result,
247-
]);
248-
249-
$this->record->refresh();
250-
251-
if ($result) {
252-
Notification::make()
253-
->title('Plugin synced successfully')
254-
->body("README, versions, and metadata have been updated for '{$this->record->name}'.")
255-
->success()
256-
->send();
257-
} else {
258-
Notification::make()
259-
->title('Sync failed')
260-
->body('Could not fetch repository data. Check the repository URL and try again.')
261-
->danger()
262-
->send();
263-
}
264-
} catch (\Throwable $e) {
265-
Log::error('[Filament:Resync] Exception', [
266-
'plugin_id' => $this->record->id,
267-
'error' => $e->getMessage(),
268-
'trace' => $e->getTraceAsString(),
269-
]);
233+
SyncPlugin::dispatch($this->record);
270234

271-
Notification::make()
272-
->title('Sync error')
273-
->body($e->getMessage())
274-
->danger()
275-
->send();
276-
}
235+
Notification::make()
236+
->title('Sync queued')
237+
->body("A background sync has been queued for '{$this->record->name}'. Refresh the page in a moment to see updates.")
238+
->success()
239+
->send();
277240
}),
278241

279242
Actions\Action::make('viewGithub')

routes/web.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -328,20 +328,3 @@
328328
Route::get('onboarding/refresh', [DeveloperOnboardingController::class, 'refresh'])->name('onboarding.refresh');
329329
Route::get('dashboard', [DeveloperOnboardingController::class, 'dashboard'])->name('dashboard');
330330
});
331-
332-
Route::get('test-sync/{id}', function (int $id) {
333-
$plugin = \App\Models\Plugin::findOrFail($id);
334-
logger('[TestSync] Starting', ['plugin_id' => $plugin->id, 'name' => $plugin->name]);
335-
336-
$syncService = new \App\Services\PluginSyncService;
337-
$result = $syncService->sync($plugin);
338-
339-
logger('[TestSync] Done', ['result' => $result]);
340-
341-
return response()->json([
342-
'result' => $result,
343-
'last_synced_at' => $plugin->fresh()->last_synced_at,
344-
'has_readme' => $plugin->fresh()->readme_html !== null,
345-
'readme_length' => strlen($plugin->fresh()->readme_html ?? ''),
346-
]);
347-
});

0 commit comments

Comments
 (0)