- install https://getcomposer.org/
cd
to script directory- execute
composer install
- run script
php tempo-async.php
Created
December 28, 2018 10:15
-
-
Save Gemorroj/97df5b1d3a50534dfa6fc21ae7f41813 to your computer and use it in GitHub Desktop.
tempo.io 429 - to many requests
This file contains 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
{ | |
"name": "gemorroj/tempo-parallel", | |
"type": "project", | |
"license": "MIT", | |
"require": { | |
"php": "^7.1.3", | |
"ext-curl": "*", | |
"ext-json": "*", | |
"guzzlehttp/guzzle": "^6.3" | |
}, | |
"autoload": { | |
"files": ["tempo-async.php"] | |
} | |
} |
This file contains 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 | |
require __DIR__.'/vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
use GuzzleHttp\Promise; | |
$issueKeys = [ | |
'SITE-1593', | |
'SITE-1517', | |
'SITE-1500', | |
'SITE-1484', | |
'SITE-1466', | |
'SITE-1430', | |
'SITE-1287', | |
'SITE-1277', | |
'SITE-1275', | |
'SITE-1266', | |
'SITE-1255', | |
'SITE-1230', | |
'SITE-1209', | |
'SITE-1202', | |
'SITE-1201', | |
'SITE-1186', | |
'SITE-1033', | |
'SITE-984', | |
'SITE-927', | |
'SITE-683', | |
'SITE-241', | |
'SITE-199', | |
'SITE-174', | |
'SITE-172', | |
'SITE-78', | |
]; | |
$httpClient = new Client([ | |
'base_uri' => 'https://api.tempo.io', | |
'headers' => [ | |
'Accept-Encoding' => 'gzip,deflate', | |
'User-Agent' => 'amasty-report', | |
'Authorization' => 'Bearer !!!SECRET-TOKEN!!!', //add your token | |
], | |
]); | |
$promises = []; | |
foreach ($issueKeys as $issueKey) { | |
$promises[$issueKey] = $httpClient->getAsync('/2/worklogs/issue/'.$issueKey, ['query' => ['limit' => 1000]]); | |
} | |
$errors = []; | |
$worklogs = []; | |
foreach (Promise\settle($promises)->wait() as $issueKey => $response) { | |
if ('fulfilled' === $response['state']) { | |
$worklogs[$issueKey] = \json_decode($response['value']->getBody(), true)['results']; | |
} else { | |
$errors[$issueKey] = $response['reason']; | |
} | |
} | |
//print_r($worklogs); | |
// print_r($errors); | |
foreach ($errors as $error) { | |
echo $error->getMessage() . PHP_EOL; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment