Created
May 15, 2024 08:03
-
-
Save whoisdevd/01f47fc7bf19e135d7847601b15e3979 to your computer and use it in GitHub Desktop.
PASS Migration Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use App\PassPlusMigration; | |
use App\Services\CreatePassAccountService; | |
use App\Services\Pictime\PictimeSQSRestoreService; | |
function processTickets() | |
{ | |
$tickets = [ | |
[ | |
'account_id' => 31748, | |
'projects' => [36746968], | |
], | |
[ | |
'account_id' => 170294, | |
'projects' => [36806959], | |
], | |
[ | |
'account_id' => 373704, | |
'projects' => [36828321, 36828011], | |
], | |
[ | |
'account_id' => 293732, | |
'projects' => [37315807], | |
], | |
[ | |
'account_id' => 81511, | |
'projects' => [36727387, 36727643, 36727238, 36727365, 36727271], | |
], | |
[ | |
'account_id' => 373610, | |
'projects' => [36614065], | |
], | |
[ | |
'account_id' => 171758, | |
'projects' => [37395974], | |
], | |
// New tickets | |
[ | |
'account_id' => 293732, | |
'projects' => [37315807], | |
], | |
[ | |
'account_id' => 170294, | |
'projects' => [36806959], | |
], | |
[ | |
'account_id' => 239746, | |
'projects' => [37064725], | |
], | |
[ | |
'account_id' => 34541, | |
'projects' => [36481325, 36481422], | |
], | |
// All galleries | |
[ | |
'account_id' => 3047468, | |
], | |
[ | |
'account_id' => 66122, | |
], | |
[ | |
'account_id' => 308345, | |
], | |
[ | |
'account_id' => 374749, | |
], | |
[ | |
'account_id' => 20153, | |
] | |
]; | |
// $sqsService = new PictimeSQSRestoreService(config('sqs-plain.queue.restore_requests')); | |
$classicDB = DB::connection('classic-db'); | |
foreach ($tickets as $i => $ticket) { | |
$migration = PassPlusMigration::where('pass_plus_account_id', $ticket['account_id'])->first(); | |
if (! $migration) { | |
Log::error('Account not found', ['i' => $i, 'account_id' => $ticket['account_id']]); | |
continue; | |
} | |
$tickets[$i]['migration_id'] = $migration->id; | |
$tickets[$i]['account_email'] = $migration->email; | |
if (! isset($ticket['projects'])) { continue;} | |
$galleryService = new CreatePassGalleryService($ticket['account_id']); | |
foreach ($ticket['projects'] as $j => $projectId) { | |
$details = $galleryService->getGalleryDetails($projectId); | |
$externalRef = $details['externalRef']; | |
list($migrationId, $eventId) = explode('-', $externalRef); | |
$classicEvent = $classicDB->table('event')->where('event_id', $eventId)->first(); | |
// $migration = PassPlusMigration::find($migrationId); | |
// $tickets[$i]['migration_id'] = $migrationId; | |
// $tickets[$i]['account_email'] = $migration->email; | |
$tickets[$i]["galleries"]["$projectId"] = [ | |
'name' => $details['name'], | |
'classic_event_id' => $eventId, | |
'project_id' => $projectId, | |
'gallery_url' => $details['galleryURL'], | |
'editing_url' => $details['editingURL'], | |
'num_photos' => optional($classicEvent)->num_items, | |
]; | |
} | |
echo ($i + 1) . PHP_EOL; | |
} | |
Log::debug('Tickets', $tickets); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment