Handle syncing errors more consistently
This commit is contained in:
parent
09f9aa2069
commit
11068029e8
@ -41,9 +41,9 @@
|
|||||||
"robmorgan/phinx": "^0.9.1",
|
"robmorgan/phinx": "^0.9.1",
|
||||||
"sebastian/phpcpd": "^3.0",
|
"sebastian/phpcpd": "^3.0",
|
||||||
"spatie/phpunit-snapshot-assertions": "^1.2.0",
|
"spatie/phpunit-snapshot-assertions": "^1.2.0",
|
||||||
"squizlabs/php_codesniffer": "^3.0.0@beta",
|
"squizlabs/php_codesniffer": "^3.2.2",
|
||||||
"symfony/var-dumper": "^4.0.1",
|
"symfony/var-dumper": "^4.0.1",
|
||||||
"theseer/phpdox": "^0.10.1",
|
"theseer/phpdox": "^0.11.0",
|
||||||
"filp/whoops": "^2.1"
|
"filp/whoops": "^2.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -49,7 +49,7 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
protected $malModel;
|
protected $malModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the image conversion script
|
* Run the Kitsu <=> MAL sync script
|
||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param array $options
|
* @param array $options
|
||||||
@ -112,7 +112,6 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
|
|
||||||
if ( ! empty($data['updateKitsu']))
|
if ( ! empty($data['updateKitsu']))
|
||||||
{
|
{
|
||||||
// print_r($data['updateKitsu']);
|
|
||||||
$count = count($data['updateKitsu']);
|
$count = count($data['updateKitsu']);
|
||||||
$this->echoBox("Updating {$count} outdated Kitsu {$type} list items");
|
$this->echoBox("Updating {$count} outdated Kitsu {$type} list items");
|
||||||
$this->updateKitsuListItems($data['updateKitsu'], $type);
|
$this->updateKitsuListItems($data['updateKitsu'], $type);
|
||||||
@ -467,14 +466,16 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
|
|
||||||
foreach($responses as $key => $response)
|
foreach($responses as $key => $response)
|
||||||
{
|
{
|
||||||
|
$responseData = Json::decode($response);
|
||||||
|
|
||||||
$id = $itemsToUpdate[$key]['id'];
|
$id = $itemsToUpdate[$key]['id'];
|
||||||
if ($response->getStatus() === 200)
|
if ( ! array_key_exists('errors', $responseData))
|
||||||
{
|
{
|
||||||
$this->echoBox("Successfully updated Kitsu {$type} list item with id: {$id}");
|
$this->echoBox("Successfully updated Kitsu {$type} list item with id: {$id}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo $response->getBody();
|
dump($responseData);
|
||||||
$this->echoBox("Failed to update Kitsu {$type} list item with id: {$id}");
|
$this->echoBox("Failed to update Kitsu {$type} list item with id: {$id}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,7 +496,7 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
foreach($responses as $key => $response)
|
foreach($responses as $key => $response)
|
||||||
{
|
{
|
||||||
$id = $itemsToUpdate[$key]['mal_id'];
|
$id = $itemsToUpdate[$key]['mal_id'];
|
||||||
if ($response->getBody() === 'Updated')
|
if ($response === 'Updated')
|
||||||
{
|
{
|
||||||
$this->echoBox("Successfully updated MAL {$type} list item with id: {$id}");
|
$this->echoBox("Successfully updated MAL {$type} list item with id: {$id}");
|
||||||
}
|
}
|
||||||
@ -518,14 +519,17 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
|
|
||||||
foreach($responses as $key => $response)
|
foreach($responses as $key => $response)
|
||||||
{
|
{
|
||||||
|
$responseData = Json::decode($response);
|
||||||
|
|
||||||
$id = $itemsToAdd[$key]['id'];
|
$id = $itemsToAdd[$key]['id'];
|
||||||
if ($response->getStatus() === 201)
|
|
||||||
|
if ( ! array_key_exists('errors', $responseData))
|
||||||
{
|
{
|
||||||
$this->echoBox("Successfully created Kitsu {$type} list item with id: {$id}");
|
$this->echoBox("Successfully created Kitsu {$type} list item with id: {$id}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo $response->getBody();
|
dump($responseData);
|
||||||
$this->echoBox("Failed to create Kitsu {$type} list item with id: {$id}");
|
$this->echoBox("Failed to create Kitsu {$type} list item with id: {$id}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -547,7 +551,7 @@ class SyncKitsuWithMal extends BaseCommand {
|
|||||||
foreach($responses as $key => $response)
|
foreach($responses as $key => $response)
|
||||||
{
|
{
|
||||||
$id = $itemsToAdd[$key]['mal_id'];
|
$id = $itemsToAdd[$key]['mal_id'];
|
||||||
if ($response->getBody() === 'Created')
|
if ($response === 'Created')
|
||||||
{
|
{
|
||||||
$this->echoBox("Successfully created MAL {$type} list item with id: {$id}");
|
$this->echoBox("Successfully created MAL {$type} list item with id: {$id}");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user