used start date as joined date instead of created at

This commit is contained in:
Kwesi Banson
2026-09-24 23:01:41 +00:00
parent 3ece39efe3
commit b4fcf65293
4 changed files with 137 additions and 9 deletions

View File

@@ -50,7 +50,8 @@ class SyncSubscriptionsServices extends Command
// Quick ping to verify credentials before running massive queries
$dynamicDb->getPdo();
} catch (Exception $e) {
}
catch (Exception $e) {
$this->error("Connection failed for {$service->name}: " . $e->getMessage());
continue; // Skip to the next service on failure
}
@@ -59,9 +60,11 @@ class SyncSubscriptionsServices extends Command
try {
if ($service->schema_type === 'type_a') {
$this->syncTypeA($dynamicDb, $service->id, $lastSync);
} elseif ($service->schema_type === 'type_b') {
}
elseif ($service->schema_type === 'type_b') {
$this->syncTypeB($dynamicDb, $service->id, $lastSync);
} else {
}
else {
$this->warn("Unknown schema type '{$service->schema_type}' for {$service->name}. Skipping.");
continue;
}
@@ -73,7 +76,8 @@ class SyncSubscriptionsServices extends Command
$this->info("Successfully synced {$service->name} up to {$syncStartTime}");
} catch (Exception $e) {
}
catch (Exception $e) {
// If it fails, the last_synced_at is not updated.
// The next run will safely pick up from the previous successful mark.
$this->error("Failed syncing {$service->name}: " . $e->getMessage());
@@ -100,9 +104,9 @@ class SyncSubscriptionsServices extends Command
$normalizedData[] = [
'service_id' => $serviceId,
'phone_number' => $subscription->msisdn,
'content_name' => $subscription->content ?? 'Standard Bundle',
'content_name' => $subscription->content ?? 'Standard',
'status' => ($subscription->status == 'ON') ? 'active' : 'inactive',
'join_date' => $subscription->created_at,
'join_date' => $subscription->start_date,
'updated_at' => now(),
'created_at' => now(),
];
@@ -131,7 +135,7 @@ class SyncSubscriptionsServices extends Command
$normalizedData[] = [
'service_id' => $serviceId,
'phone_number' => $sub->cell_number,
'content_name' => $sub->content ?? 'Standard Bundle', // Added to match composite key
'content_name' => $sub->content ?? 'Standard', // Added to match composite key
'status' => strtolower($sub->sub_state),
'join_date' => $sub->date_joined,
'updated_at' => now(),