Skip to content

Commit

Permalink
Adjust offset handling
Browse files Browse the repository at this point in the history
  • Loading branch information
marcreichel committed Jan 10, 2019
1 parent 86eda7a commit 4f2fc9d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

/*
* This is the per-page limit for your tier ("Free" by default)
* Adjust this to 500 if you are on the "Pro" tier or to whatever you want
* if you are in the Partner Program.
* Adjust this to 500 if you are on the "Pro" tier or in the Partner Program
* or to 5000 if you are in the "Enterprise" tier.
*/
'per_page_limit' => 50,

/*
* This is the offset limit for your tier ("Free" by default)
* Adjust this to 5000 if you are on the "Pro" tier or to whatever you want
* if you are in the Partner Program.
* Adjust this to 5000 if you are on the "Pro" tier or in the Partner Program
* or to 0 (to turn it off) if you are in the "Enterprise" tier.
*/
'offset_limit' => 150,
];
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ return [

/*
* This is the per-page limit for your tier ("Free" by default)
* Adjust this to 500 if you are on the "Pro" tier or to whatever you want
* if you are in the Partner Program.
* Adjust this to 500 if you are on the "Pro" tier or in the Partner Program
* or to 5000 if you are in the "Enterprise" tier.
*/
'per_page_limit' => 50,

/*
* This is the offset limit for your tier ("Free" by default)
* Adjust this to 5000 if you are on the "Pro" tier or to whatever you want
* if you are in the Partner Program.
* Adjust this to 5000 if you are on the "Pro" tier or in the Partner Program
* or to 0 (to turn it off) if you are in the "Enterprise" tier.
*/
'offset_limit' => 150,
];
Expand Down
11 changes: 8 additions & 3 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,13 @@ public function take(int $limit): self
*/
public function offset(int $offset): self
{
$offset = min($offset, config('igdb.offset_limit', 150));
$this->query->put('offset', $offset);
$tierMaximum = max(0, config('igdb.offset_limit', 150));
if ($tierMaximum === 0) {
$this->query->put('offset', $offset);
} else {
$offset = min($offset, config('igdb.offset_limit', 150));
$this->query->put('offset', $offset);
}

return $this;
}
Expand Down Expand Up @@ -1323,7 +1328,7 @@ private function handleRequestException($exception)
$message = 'Invalid User key or no user key';
throw new UnauthorizedException($message);
}
} elseif($exception instanceof ServerException) {
} elseif ($exception instanceof ServerException) {
if ($exception->getCode() === Response::HTTP_SERVICE_UNAVAILABLE) {
$message = 'IGDB is down right now. Please try again later.';
throw new ServiceUnavailableException($message);
Expand Down

0 comments on commit 4f2fc9d

Please sign in to comment.