Update dependencies, use ParallelAPIRequest

This commit is contained in:
Timothy Warren 2017-03-28 11:01:38 -04:00
parent b8b5beeae1
commit 394c1241fb
3 changed files with 11 additions and 7 deletions

View File

@ -4,6 +4,7 @@
* Updated to use Kitsu API after discontinuation of Hummingbird
* Added streaming links to list entries from the Kitsu API
* Added simple integration with MyAnimeList, so an update can cross-post to both Kitsu and MyAnimeList
* Added character pages
## Version 3
* Converted user configuration to toml files

View File

@ -21,7 +21,7 @@
"aura/router": "^3.0",
"aura/session": "^2.0",
"aviat/banker": "^1.0.0",
"aviat/ion": "dev-master",
"aviat/ion": "^2.0.0",
"monolog/monolog": "^1.0",
"psr/http-message": "~1.0",
"psr/log": "~1.0",

View File

@ -19,7 +19,12 @@ namespace Aviat\AnimeClient\API\Kitsu;
use function Amp\{all, wait};
use Amp\Artax\{Client, Request};
use Aviat\AnimeClient\API\{CacheTrait, JsonAPI, Kitsu as K};
use Aviat\AnimeClient\API\{
CacheTrait,
JsonAPI,
Kitsu as K,
ParallelAPIRequest
};
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\Title,
AnimeWatchingStatus\Kitsu as KitsuWatchingStatus,
@ -343,18 +348,16 @@ class Model {
$size = 100;
$pages = ceil($count / $size);
$requests = [];
$requester = new ParallelAPIRequest();
// Set up requests
for ($i = 0; $i < $pages; $i++)
{
$offset = $i * $size;
$requests[] = $this->getPagedAnimeList($size, $offset, $options);
$requester->addRequest($this->getPagedAnimeList($size, $offset, $options));
}
$promiseArray = (new Client())->requestMulti($requests);
$responses = wait(all($promiseArray));
$responses = $requester->makeRequests();
$output = [];
foreach($responses as $response)