Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2597: Changed how epics are synchronized #185

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Model/Invoices/IssueData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Model\Invoices;

use App\Entity\Epic;
use App\Enum\IssueStatusEnum;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
Expand All @@ -18,8 +17,7 @@ class IssueData
public ?string $accountKey = null;
public ?string $epicName = null;
public ?string $epicKey = null;
/** @var Collection<int, Epic> */
public Collection $epics;
public array $epics;
/** @var Collection<string, VersionData> */
public Collection $versions;
public ?\DateTime $resolutionDate = null;
Expand All @@ -32,7 +30,6 @@ class IssueData

public function __construct()
{
$this->epics = new ArrayCollection();
$this->versions = new ArrayCollection();
}
}
5 changes: 0 additions & 5 deletions src/Service/DataProviderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Exception\EconomicsException;
use App\Exception\UnsupportedDataProviderException;
use App\Interface\DataProviderServiceInterface;
use App\Repository\EpicRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
use Symfony\Component\HttpClient\RetryableHttpClient;
Expand All @@ -31,7 +30,6 @@ public function __construct(
protected readonly int $httpClientRetryDelayMs = 1000,
protected readonly int $httpClientMaxRetries = 3,
private readonly DateTimeHelper $dateTimeHelper,
private readonly EpicRepository $epicRepository,
) {
}

Expand Down Expand Up @@ -67,7 +65,6 @@ public function getService(DataProvider $dataProvider): DataProviderServiceInter
$this->weekGoalLow,
$this->weekGoalHigh,
$this->sprintNameRegex,
$this->epicRepository
);
break;
case LeantimeApiService::class:
Expand All @@ -87,8 +84,6 @@ public function getService(DataProvider $dataProvider): DataProviderServiceInter
$this->weekGoalHigh,
$this->sprintNameRegex,
$this->dateTimeHelper,
$this->epicRepository,
$this->entityManager
);
break;
default:
Expand Down
20 changes: 17 additions & 3 deletions src/Service/DataSynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Entity\Account;
use App\Entity\Client;
use App\Entity\DataProvider;
use App\Entity\Epic;
use App\Entity\Invoice;
use App\Entity\Issue;
use App\Entity\Project;
Expand All @@ -18,6 +19,7 @@
use App\Repository\AccountRepository;
use App\Repository\ClientRepository;
use App\Repository\DataProviderRepository;
use App\Repository\EpicRepository;
use App\Repository\InvoiceRepository;
use App\Repository\IssueRepository;
use App\Repository\ProjectRepository;
Expand All @@ -44,7 +46,7 @@ public function __construct(
private readonly InvoiceRepository $invoiceRepository,
private readonly DataProviderService $dataProviderService,
private readonly DataProviderRepository $dataProviderRepository,
private readonly WorkerRepository $workerRepository,
private readonly WorkerRepository $workerRepository, private readonly EpicRepository $epicRepository,
) {
}

Expand Down Expand Up @@ -271,8 +273,20 @@ public function syncIssuesForProject(int $projectId, ?callable $progressCallback
}
}

foreach ($issueDatum->epics as $epicData) {
$issue->addEpic($epicData);
foreach ($issueDatum->epics as $epicTitle) {
if (empty($epicTitle)) {
continue;
}
$epic = $this->epicRepository->findOneBy(['title' => $epicTitle]);

if (null === $epic) {
$epic = new Epic();
$epic->setTitle($epicTitle);
$this->entityManager->persist($epic);
$this->entityManager->flush();
}

$issue->addEpic($epic);
}

if (null !== $progressCallback) {
Expand Down
20 changes: 1 addition & 19 deletions src/Service/JiraApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Service;

use App\Entity\Epic;
use App\Enum\ClientTypeEnum;
use App\Enum\IssueStatusEnum;
use App\Exception\ApiServiceException;
Expand All @@ -17,10 +16,7 @@
use App\Model\Invoices\VersionData;
use App\Model\Invoices\WorklogData;
use App\Model\Invoices\WorklogDataCollection;
use App\Model\Planning\Issue;
use App\Model\Planning\PlanningData;
use App\Model\Planning\Project;
use App\Model\Planning\Sprint;
use App\Model\SprintReport\SprintReportData;
use App\Model\SprintReport\SprintReportEpic;
use App\Model\SprintReport\SprintReportIssue;
Expand All @@ -30,7 +26,6 @@
use App\Model\SprintReport\SprintReportVersion;
use App\Model\SprintReport\SprintReportVersions;
use App\Model\SprintReport\SprintStateEnum;
use App\Repository\EpicRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Contracts\HttpClient\HttpClientInterface;

Expand All @@ -55,7 +50,6 @@ public function __construct(
protected readonly float $weekGoalLow,
protected readonly float $weekGoalHigh,
protected readonly string $sprintNameRegex,
private readonly EpicRepository $epicRepository,
) {
}

Expand Down Expand Up @@ -741,19 +735,7 @@ public function getIssuesDataForProjectPaged(string $projectId, $startAt = 0, $m
$issueData->epicKey = $epicKey;
$issueData->epicName = $epicData->fields->summary ?? null;

$epic = $this->epicRepository->findOneBy([
'title' => $epicData->fields->summary,
]);

if (!$epic && !empty($epicData->fields->summary)) {
$epic = new Epic();
$epic->setTitle($epicData->fields->summary);
$this->epicRepository->save($epic);
}

if ($epic) {
$issueData->epics->add($epic);
}
$issueData->epics = [$epicData->fields->summary];
}

foreach ($fields->fixVersions ?? [] as $fixVersion) {
Expand Down
27 changes: 1 addition & 26 deletions src/Service/LeantimeApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Service;

use App\Entity\Epic;
use App\Enum\IssueStatusEnum;
use App\Exception\ApiServiceException;
use App\Exception\EconomicsException;
Expand Down Expand Up @@ -30,9 +29,7 @@
use App\Model\SprintReport\SprintReportVersion;
use App\Model\SprintReport\SprintReportVersions;
use App\Model\SprintReport\SprintStateEnum;
use App\Repository\EpicRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Uid\Ulid;
use Symfony\Contracts\HttpClient\HttpClientInterface;

Expand Down Expand Up @@ -62,8 +59,6 @@ public function __construct(
protected readonly float $weekGoalHigh,
protected readonly string $sprintNameRegex,
private readonly DateTimeHelper $dateTimeHelper,
private readonly EpicRepository $epicRepository,
private readonly EntityManagerInterface $entityManager,
) {
}

Expand Down Expand Up @@ -198,27 +193,7 @@ public function getIssuesDataForProjectPaged(string $projectId, $startAt = 0, $m
$issueData->epicKey = $issue->tags;
$issueData->epicName = $issue->tags;

$epicArray = explode(',', $issue->tags);

foreach ($epicArray as $epicTitle) {
if (empty($epicTitle)) {
continue;
}
$epic = $this->epicRepository->findOneBy([
'title' => $epicTitle,
]);

if (!$epic) {
$epic = new Epic();
$epic->setTitle($epicTitle);
$this->epicRepository->save($epic);
$this->entityManager->flush();
}

if ($epic) {
$issueData->epics->add($epic);
}
}
$issueData->epics = explode(',', $issue->tags);

$issueData->planHours = $issue->planHours;
$issueData->hourRemaining = $issue->hourRemaining;
Expand Down
Loading