Skip to content

Commit

Permalink
no-task Refactor GitLabClient to handle null start and end dates for …
Browse files Browse the repository at this point in the history
…Jira sprints.
  • Loading branch information
Dominik Bähr committed Sep 25, 2023
1 parent 3296475 commit a745451
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/AiJira/GitLab/GitLabClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ class GitLabClient
{
public function getMergeRequestsForJiraSprint(array $jiraSprint): array
{
$startDate = new \DateTimeImmutable($jiraSprint['startDate']);
$endDate = new \DateTimeImmutable($jiraSprint['endDate']);

$mergeRequests = [];

$startDate = $jiraSprint['startDate'] ?? null;
$endDate = $jiraSprint['endDate'] ?? null;

if (!$startDate || !$endDate) {
return $mergeRequests;
}

$startDate = new \DateTimeImmutable($startDate);
$endDate = new \DateTimeImmutable($endDate);
foreach (explode(',', getenv('AI_GITLAB_PROJECT_IDS')) as $gitlabProjectID) {
$mergeRequests = array_merge($mergeRequests, $this->getMergeRequestsByDateRange($gitlabProjectID, $startDate, $endDate));
}
Expand Down

0 comments on commit a745451

Please sign in to comment.