Skip to content

Commit

Permalink
Merge pull request #26 from Flowpack/feature-show-publish-triggering-…
Browse files Browse the repository at this point in the history
…user-in-overview

FEATURE: Show username of user that triggered publish
  • Loading branch information
JamesAlias authored May 8, 2023
2 parents aacc7f3 + d4e9644 commit de4e90e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
5 changes: 2 additions & 3 deletions Classes/Command/ContentReleasePrepareCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ class ContentReleasePrepareCommandController extends CommandController
*/
protected $concurrentBuildLock;

public function createContentReleaseCommand(string $contentReleaseIdentifier, string $prunnerJobId, string $workspaceName = 'live'): void
public function createContentReleaseCommand(string $contentReleaseIdentifier, string $prunnerJobId, string $workspaceName = 'live', string $accountId = 'cli'): void
{
$contentReleaseIdentifier = ContentReleaseIdentifier::fromString($contentReleaseIdentifier);
$prunnerJobId = PrunnerJobId::fromString($prunnerJobId);
$logger = ContentReleaseLogger::fromConsoleOutput($this->output, $contentReleaseIdentifier);

$this->redisContentReleaseService->createContentRelease($contentReleaseIdentifier, $prunnerJobId, $logger, $workspaceName);
$this->redisContentReleaseService->createContentRelease($contentReleaseIdentifier, $prunnerJobId, $logger, $workspaceName, $accountId);
}

public function ensureAllOtherInProgressContentReleasesWillBeTerminatedCommand(string $contentReleaseIdentifier): void
Expand Down
9 changes: 9 additions & 0 deletions Classes/ContentReleaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Neos\Flow\Annotations as Flow;
use Flowpack\Prunner\PrunnerApiService;
use Flowpack\Prunner\ValueObject\PipelineName;
use Neos\Flow\Security\Context;
use Neos\Fusion\Core\Cache\ContentCache;

/**
Expand Down Expand Up @@ -43,6 +44,12 @@ class ContentReleaseManager
*/
protected $configEpochSettings;

/**
* @FLow\Inject
* @var Context
*/
protected $securityContext;

const REDIS_CURRENT_RELEASE_KEY = 'contentStore:current';
const NO_PREVIOUS_RELEASE = 'NO_PREVIOUS_RELEASE';

Expand All @@ -61,6 +68,7 @@ public function startIncrementalContentRelease(string $currentContentReleaseId =
'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE,
'validate' => true,
'workspaceName' => $workspace ? $workspace->getName() : 'live',
'accountId' => $this->securityContext->getAccount()->getAccountIdentifier(),
]));
return $contentReleaseId;
}
Expand All @@ -80,6 +88,7 @@ public function startFullContentRelease(bool $validate = true, string $currentCo
'currentContentReleaseId' => $currentContentReleaseId ?: self::NO_PREVIOUS_RELEASE,
'validate' => $validate,
'workspaceName' => $workspace ? $workspace->getName() : 'live',
'accountId' => $this->securityContext->getAccount()->getAccountIdentifier(),
]));
return $contentReleaseId;
}
Expand Down
30 changes: 20 additions & 10 deletions Classes/PrepareContentRelease/Dto/ContentReleaseMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Flowpack\DecoupledContentStore\Core\Domain\ValueObject\ContentReleaseIdentifier;
use Flowpack\DecoupledContentStore\Core\Domain\ValueObject\PrunnerJobId;
use Flowpack\DecoupledContentStore\NodeRendering\Dto\NodeRenderingCompletionStatus;
use Neos\ContentRepository\Domain\Model\Workspace;
use Neos\Flow\Annotations as Flow;

/**
Expand Down Expand Up @@ -41,14 +40,17 @@ final class ContentReleaseMetadata implements \JsonSerializable

private ?string $workspaceName;

private ?string $accountId;

private function __construct(
PrunnerJobId $prunnerJobId,
?\DateTimeInterface $startTime,
?\DateTimeInterface $endTime,
?\DateTimeInterface $switchTime,
?NodeRenderingCompletionStatus $status,
?array $manualTransferJobIds = [],
string $workspaceName = 'live'
string $workspaceName = 'live',
?string $accountId = 'cli'
)
{
$this->prunnerJobId = $prunnerJobId;
Expand All @@ -58,12 +60,13 @@ private function __construct(
$this->status = $status ?: NodeRenderingCompletionStatus::scheduled();
$this->manualTransferJobIds = $manualTransferJobIds;
$this->workspaceName = $workspaceName;
$this->accountId = $accountId;
}


public static function create(PrunnerJobId $prunnerJobId, \DateTimeInterface $startTime, string $workspace = 'live'): self
public static function create(PrunnerJobId $prunnerJobId, \DateTimeInterface $startTime, string $workspace = 'live', string $accountId = 'cli'): self
{
return new self($prunnerJobId, $startTime, null, null, NodeRenderingCompletionStatus::scheduled(), [], $workspace);
return new self($prunnerJobId, $startTime, null, null, NodeRenderingCompletionStatus::scheduled(), [], $workspace, $accountId);
}

public static function fromJsonString($metadataEncoded, ContentReleaseIdentifier $contentReleaseIdentifier): self
Expand All @@ -85,7 +88,8 @@ public static function fromJsonString($metadataEncoded, ContentReleaseIdentifier
isset($tmp['manualTransferJobIds']) ? array_map(function (string $item) {
return PrunnerJobId::fromString($item);
}, json_decode($tmp['manualTransferJobIds'])) : [],
$tmp['workspace'] ?? 'live'
$tmp['workspace'] ?? 'live',
key_exists('accountId', $tmp) ? $tmp['accountId'] : 'cli',
);
}

Expand All @@ -99,30 +103,31 @@ public function jsonSerialize(): array
'switchTime' => $this->switchTime ? $this->switchTime->format(\DateTime::RFC3339_EXTENDED) : null,
'status' => $this->status,
'manualTransferJobIds' => json_encode($this->manualTransferJobIds),
'workspaceName' => $this->workspaceName
'workspaceName' => $this->workspaceName,
'accountId' => $this->accountId,
];
}

public function withEndTime(\DateTimeInterface $endTime): self
{
return new self($this->prunnerJobId, $this->startTime, $endTime, $this->switchTime, $this->status, $this->manualTransferJobIds);
return new self($this->prunnerJobId, $this->startTime, $endTime, $this->switchTime, $this->status, $this->manualTransferJobIds, $this->workspaceName, $this->accountId);
}

public function withSwitchTime(\DateTimeInterface $switchTime): self
{
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $switchTime, $this->status, $this->manualTransferJobIds);
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $switchTime, $this->status, $this->manualTransferJobIds, $this->workspaceName, $this->accountId);
}

public function withStatus(NodeRenderingCompletionStatus $status): self
{
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $status, $this->manualTransferJobIds);
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $status, $this->manualTransferJobIds, $this->workspaceName, $this->accountId);
}

public function withAdditionalManualTransferJobId(PrunnerJobId $prunnerJobId): self
{
$manualTransferIdArray = self::getManualTransferJobIds();
$manualTransferIdArray[] = $prunnerJobId;
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $this->status, $manualTransferIdArray);
return new self($this->prunnerJobId, $this->startTime, $this->endTime, $this->switchTime, $this->status, $manualTransferIdArray, $this->workspaceName, $this->accountId);
}

public function getPrunnerJobId(): PrunnerJobId
Expand Down Expand Up @@ -163,4 +168,9 @@ public function getWorkspaceName(): ?string
return $this->workspaceName;
}

public function getAccountId(): ?string
{
return $this->accountId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class RedisContentReleaseService
*/
protected $redisContentReleaseService;

public function createContentRelease(ContentReleaseIdentifier $contentReleaseIdentifier, PrunnerJobId $prunnerJobId, ContentReleaseLogger $contentReleaseLogger, string $workspaceName = 'live'): void
public function createContentRelease(ContentReleaseIdentifier $contentReleaseIdentifier, PrunnerJobId $prunnerJobId, ContentReleaseLogger $contentReleaseLogger, string $workspaceName = 'live', string $accountId = 'cli'): void
{
$redis = $this->redisClientManager->getPrimaryRedis();
$metadata = ContentReleaseMetadata::create($prunnerJobId, new \DateTimeImmutable(), $workspaceName);
$metadata = ContentReleaseMetadata::create($prunnerJobId, new \DateTimeImmutable(), $workspaceName, $accountId);
$redis->multi();
try {
$redis->zAdd('contentStore:registeredReleases', 0, $contentReleaseIdentifier->getIdentifier());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Flowpack.DecoupledContentStore.BackendController.index = Neos.Fusion:Component {
<span @if.isActive={item.active} class="neos-badge neos-badge-info">active</span>
<span @if.errors={item.errorCount} class="neos-badge neos-badge-important" title="errors" data-neos-toggle="tooltip">{item.errorCount}</span>
</td>
<td>{item.metadata.accountId}</td>
<td>
{props.enumeratedDocumentNodesCount}
</td>
Expand Down Expand Up @@ -93,6 +94,7 @@ Flowpack.DecoupledContentStore.BackendController.index = Neos.Fusion:Component {
<thead>
<tr>
<th style="width: 240px">Identifier</th>
<th>Author</th>
<th style="width: 200px">Page Count</th>
<th style="width: 200px">Render Progress</th>
<th style="width: 200px">Iterations</th>
Expand Down
2 changes: 1 addition & 1 deletion pipelines_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pipelines:
################################################################################
prepare_finished:
script:
- ./flow contentReleasePrepare:createContentRelease {{ .contentReleaseId }} {{ .__jobID }} {{ .workspaceName }}
- ./flow contentReleasePrepare:createContentRelease {{ .contentReleaseId }} {{ .__jobID }} --workspaceName {{ .workspaceName }} --accountId {{ .accountId }}
- ./flow contentReleasePrepare:ensureAllOtherInProgressContentReleasesWillBeTerminated {{ .contentReleaseId }}

################################################################################
Expand Down

0 comments on commit de4e90e

Please sign in to comment.