mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-03 04:46:18 +00:00
feat(jobs): optimize async job dispatches and enhance Stripe subscription sync
Reduce unnecessary job queue pressure and improve subscription sync reliability: - Cache ServerStorageCheckJob dispatch to only trigger on disk percentage changes - Rate-limit ConnectProxyToNetworksJob to maximum once per 10 minutes - Add progress callback support to SyncStripeSubscriptionsJob for UI feedback - Implement bulk fetching of valid Stripe subscription IDs for efficiency - Detect and report resubscribed users (same email, different customer ID) - Fix CleanupUnreachableServers query operator (>= 3 instead of = 3) - Improve empty subId validation in PushServerUpdateJob - Optimize relationship access by using properties instead of query methods - Add comprehensive test coverage for all optimizations
This commit is contained in:
1 parent
6b2a669cb9
commit
f68793ed69
6 files changed
+402
-37
No files matched your search
@@ -36,7 +36,14 @@ class SyncStripeSubscriptions extends Command
|
||||
$this->newLine();
|
||||
|
||||
$job = new SyncStripeSubscriptionsJob($fix);
|
||||
$result = $job->handle();
|
||||
$fetched = 0;
|
||||
$result = $job->handle(function (int $count) use (&$fetched): void {
|
||||
$fetched = $count;
|
||||
$this->output->write("\r Fetching subscriptions from Stripe... {$fetched}");
|
||||
});
|
||||
if ($fetched > 0) {
|
||||
$this->output->write("\r".str_repeat(' ', 60)."\r");
|
||||
}
|
||||
|
||||
if (isset($result['error'])) {
|
||||
$this->error($result['error']);
|
||||
@@ -68,6 +75,19 @@ class SyncStripeSubscriptions extends Command
|
||||
$this->info('No discrepancies found. All subscriptions are in sync.');
|
||||
}
|
||||
|
||||
if (count($result['resubscribed']) > 0) {
|
||||
$this->newLine();
|
||||
$this->warn('Resubscribed users (same email, different customer): '.count($result['resubscribed']));
|
||||
$this->newLine();
|
||||
|
||||
foreach ($result['resubscribed'] as $resub) {
|
||||
$this->line(" - Team ID: {$resub['team_id']} | Email: {$resub['email']}");
|
||||
$this->line(" Old: {$resub['old_stripe_subscription_id']} (cus: {$resub['old_stripe_customer_id']})");
|
||||
$this->line(" New: {$resub['new_stripe_subscription_id']} (cus: {$resub['new_stripe_customer_id']}) [{$resub['new_status']}]");
|
||||
$this->newLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (count($result['errors']) > 0) {
|
||||
$this->newLine();
|
||||
$this->error('Errors encountered: '.count($result['errors']));
|
||||
|
||||
Reference in new issue
Block a user