Fixes for 4.1 #14

Merged
timw4mail merged 16 commits from develop into master 2018-12-13 14:51:01 -05:00
3 changed files with 20 additions and 9 deletions
Showing only changes of commit b871a4fac2 - Show all commits

View File

@ -97,11 +97,15 @@ final class UserTransformer extends AbstractTransformer {
/**
* Format the time spent on anime in a more readable format
*
* @param int $minutes
* @param int $seconds
* @return string
*/
private function formatAnimeTime(int $minutes): string
private function formatAnimeTime(int $seconds): string
{
// All the seconds left
$remSeconds = $seconds % 60;
$minutes = ($seconds - $remSeconds) / 60;
$minutesPerDay = 1440;
$minutesPerYear = $minutesPerDay * 365;
@ -111,15 +115,13 @@ final class UserTransformer extends AbstractTransformer {
// Minutes short of a day
$extraMinutes = $minutes % $minutesPerDay;
$days = ($minutes - $extraMinutes) / $minutesPerDay;
// Minutes short of an hour
$remMinutes = $extraMinutes % 60;
$hours = ($extraMinutes - $remMinutes) / 60;
$output = "{$days} days, {$hours} hours, and {$remMinutes} minutes.";
$output = "{$days} days, {$hours} hours, {$remMinutes} minutes, and {$remSeconds} seconds.";
if ($years > 0)
{

View File

@ -19,7 +19,7 @@ namespace Aviat\AnimeClient\API;
use function Amp\call;
use function Amp\Promise\{all, wait};
use Amp\Artax\DefaultClient;
use Amp\Artax\{Client, DefaultClient};
/**
* Class to simplify making and validating simultaneous requests
@ -73,6 +73,10 @@ final class ParallelAPIRequest {
public function makeRequests(): array
{
$client = new DefaultClient();
// Timeouts suck
$client->setOption(Client::OP_TRANSFER_TIMEOUT, 0);
$promises = [];
foreach ($this->requests as $key => $url)
@ -95,6 +99,10 @@ final class ParallelAPIRequest {
public function getResponses(): array
{
$client = new DefaultClient();
// Timeouts suck
$client->setOption(Client::OP_TRANSFER_TIMEOUT, 0);
$promises = [];
foreach ($this->requests as $key => $url)

View File

@ -18,8 +18,7 @@ namespace Aviat\AnimeClient;
use function Amp\Promise\wait;
use Amp\Artax\DefaultClient;
use Amp\Artax\Response;
use Amp\Artax\{Client, DefaultClient, Response};
use Aviat\Ion\ConfigInterface;
use Yosymfony\Toml\{Toml, TomlBuilder};
@ -217,7 +216,9 @@ function checkFolderPermissions(ConfigInterface $config): array
*/
function getResponse ($request): Response
{
return wait((new DefaultClient)->request($request));
$client = new DefaultClient;
$client->setOption(Client::OP_TRANSFER_TIMEOUT, 0);
return wait($client->request($request));
}
/**