Skip to content
Permalink
Browse files

Properly handle pagination of Jira users

  • Loading branch information...
kiwiz committed Jun 7, 2019
1 parent 0588917 commit 9197347550e14c69346c521e3d1c3d2ac4de4538
Showing with 13 additions and 5 deletions.
  1. +13 −5 phplib/Target/Jira.php
@@ -167,12 +167,20 @@ public static function getUsers() {
$jiracfg = Config::get('jira');
$curl = self::getCurl();
$raw_data = $curl->get(sprintf('%s/rest/api/2/user/search?username=%%&maxResults=999999', $jiracfg['host']));
if($curl->httpStatusCode < 200 || $curl->httpStatusCode >= 300) {
return null;
}
$users = [];
$offset = 0;
do {
$raw_data = $curl->get(sprintf('%s/rest/api/2/user/search?username=%%&maxResults=1000&startAt=%d', $jiracfg['host'], $offset));
if($curl->httpStatusCode < 200 || $curl->httpStatusCode >= 300) {
break;
}
return $raw_data;
$cnt = count($raw_data);
$users = array_merge($users, $raw_data);
$offset += $cnt;
} while($cnt == 1000);
return $users;
}
/**

0 comments on commit 9197347

Please sign in to comment.
You can’t perform that action at this time.