Skip to content

Commit

Permalink
Only use Jira ticket status for requested removal
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Feb 11, 2021
1 parent 8b23d97 commit 6a0be29
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.7.2
**Bugfix**
Set correct publication state for prod entities PART II #394

## 2.7.1

**Bugfix**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ class EntityService implements EntityServiceInterface
*/
private $prodManageConfig;

/**
* @var string
*/
private $publishStatus;

/**
* @var string
*/
Expand All @@ -92,7 +87,6 @@ public function __construct(
Config $productionConfig,
RouterInterface $router,
LoggerInterface $logger,
string $publishStatus,
string $removalStatus
) {
$this->queryRepositoryProvider = $entityQueryRepositoryProvider;
Expand All @@ -101,7 +95,6 @@ public function __construct(
$this->logger = $logger;
$this->testManageConfig = $testConfig;
$this->prodManageConfig = $productionConfig;
$this->publishStatus = $publishStatus;
$this->removalStatus = $removalStatus;
}

Expand Down Expand Up @@ -161,13 +154,11 @@ public function getEntityByIdAndTarget($id, $manageTarget, Service $service)
// with the service desk.
$this->updateStatus($entity);

// Todo: review this construction, The ticket is used to determine request for removal, but not for the
// publication state
$issue = $this->findIssueBy($entity);
$shouldUseTicketStatus = $entity->getStatus() !== Constants::STATE_PUBLISHED &&
$entity->getStatus() !== Constants::STATE_PUBLICATION_REQUESTED;
if ($issue && $shouldUseTicketStatus) {
$this->updateEntityStatusWithJiraTicketStatus($entity, $issue);
$entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED);
}

return $entity;
Expand Down Expand Up @@ -293,28 +284,23 @@ private function findPublishedProductionEntitiesByTeamName($teamName)
// Extract the Manage entity id's
$manageIds = [];
foreach ($entities as $entity) {
$this->updateStatus($entity);
$manageIds[] = $entity->getId();
}
$issueCollection = $this->ticketService->findByManageIds($manageIds);
// Update the entity status to STATE_REMOVAL_REQUESTED if the Jira ticket matches one of the published
// entities
if (count($issueCollection) > 0) {
foreach ($entities as $entity) {
$this->updateStatus($entity);
$issue = $issueCollection->getIssueById($entity->getId());
if ($issue && !$entity->isExcludedFromPush() && $issue->getIssueType() !== 'spd-delete-production-entity') {
if ($issue && !$entity->isExcludedFromPush() && $issue->getIssueType() !== $this->removalStatus) {
// A published entity needs no status update unless it's a removal requested entity
continue;
}

if ($issue) {
switch ($issue->getIssueType()) {
case $this->publishStatus:
$entity->updateStatus(Constants::STATE_PUBLICATION_REQUESTED);
break;
case $this->removalStatus:
$entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED);
break;
}
if ($issue && $issue->getIssueType() === $this->removalStatus) {
$entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED);
}
}
}
Expand Down Expand Up @@ -349,13 +335,6 @@ private function findIssueBy(ManageEntity $entity)
return null;
}

private function updateEntityStatusWithJiraTicketStatus(ManageEntity $entity, Issue $issue)
{
if ($issue instanceof Issue) {
$entity->updateStatus(Constants::STATE_REMOVAL_REQUESTED);
}
}

private function updateStatus(ManageEntity $entity)
{
$excludeFromPush = $entity->getMetaData()->getCoin()->getExcludeFromPush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ services:
- '@surfnet.manage.configuration.production'
- '@router'
- '@logger'
- '%jira_issue_type_publication_request%'
- '%jira_issue_type%'

Surfnet\ServiceProviderDashboard\Application\Service\LoadEntityService:
Expand Down

0 comments on commit 6a0be29

Please sign in to comment.