Skip to content

Commit

Permalink
Changes to reduce API calls for Developer & Company Apps listing
Browse files Browse the repository at this point in the history
  • Loading branch information
kedarkhaire committed Nov 21, 2024
1 parent fceb7f5 commit 1c62281
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/Controller/PaginationHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,22 +326,31 @@ private function listEntityIdsWithCps(?PagerInterface $pager = null, array $quer
if (empty($ids)) {
return [];
}
$lastId = end($ids);
do {
$tmp = $this->getResultsInRange($this->createPager(0, $lastId), $query_params, $expandCompatibility);
// Remove the first item from the list because it is the same
// as the current last item of $ids.
// Apigee Edge response always starts with the requested entity
// id (startKey).
if (count($ids) > 100) {
$lastId = end($ids);
do {
$tmp = $this->getResultsInRange($this->createPager(0, $lastId), $query_params, $expandCompatibility);
// Remove the first item from the list because it is the same
// as the current last item of $ids.
// Apigee Edge response always starts with the requested entity
// id (startKey).
array_shift($tmp);
if (count($tmp) > 0) {
$ids = array_merge($ids, $tmp);
$lastId = end($tmp);
} else {
$lastId = false;
}
} while ($lastId);
} else {
// Condition added to load the expanded details for each app in a single call.
$query_params = ['expand' => 'true'];
$tmp = $this->getResultsInRange($this->createPager(), $query_params, $expandCompatibility);
array_shift($tmp);

if (count($tmp) > 0) {
$ids = array_merge($ids, $tmp);
$lastId = end($tmp);
} else {
$lastId = false;
}
} while ($lastId);
}

return $ids;
}
Expand Down

0 comments on commit 1c62281

Please sign in to comment.