Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* (improvement) Simplify task run duration calculation.
* (improvement) Transform exception to log entry, so that the worker doesn't constantly fail.
* (deprecation) Deprecate entity getters in favor of properties.
* (improvement) Add explicit task class field.


2.3.2
Expand Down
4 changes: 2 additions & 2 deletions src/Command/TaskLogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private function showTaskDetails (TorrStyle $io, int $taskId) : int
["Task ID" => $task->id],
["Task" => $task->getTaskLabel()],
["Status" => $status],
["Task Class" => $task->getTaskClass()],
["Task Class" => $task->taskClass],
["Runs" => \count($task->runs)],
["Total Duration" => $this->formatDuration($task->getTotalDuration())],
["Handled by" => implode(" on ", $handled)],
Expand Down Expand Up @@ -218,7 +218,7 @@ private function showList (TorrStyle $io, int $limit) : void
$task->getTaskLabel() ?? "—",
),
$status,
$task->getTaskClass(),
$task->taskClass,
\count($task->runs),
$this->formatDuration($task->getTotalDuration()),
$task->timeQueued->format("c"),
Expand Down
14 changes: 11 additions & 3 deletions src/Entity/TaskLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

/**
* @phpstan-type TaskDetails array{
* "class"?: class-string|null,
* "handledBy"?: string|null,
* "label"?: string,
* "task"?: string,
Expand All @@ -40,6 +39,12 @@ class TaskLog
#[ORM\Column(type: Types::STRING, length: 50, unique: true)]
public private(set) string $taskId;

/**
*
*/
#[ORM\Column(type: Types::STRING, length: 1000)]
public string $taskClass;

/**
* The encoded task details
*
Expand All @@ -65,6 +70,7 @@ public function __construct (
Task $task,
)
{
$this->taskClass = $task::class;
$this->taskId = $task->ulid;
$this->runs = new ArrayCollection();
$this->timeQueued = now();
Expand Down Expand Up @@ -257,9 +263,11 @@ public function getTransport () : ?string

/**
* Returns the class of the message
*
* @deprecated use the property directly instead
*/
public function getTaskClass () : ?string
public function getTaskClass () : string
{
return $this->getTaskDetails()["class"] ?? null;
return $this->taskClass;
}
}
5 changes: 4 additions & 1 deletion src/Entity/TaskRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class TaskRun
*/
#[ORM\Column(type: Types::TEXT, nullable: true)]
public private(set) ?string $output = null;

/**
*/
public bool $isFinished {
get => null !== $this->duration;
}
Expand All @@ -65,7 +68,7 @@ class TaskRun
*/
public function __construct (
TaskLog $taskLog,
private ?LoggerInterface $logger = null,
private readonly ?LoggerInterface $logger = null,
)
{
$this->taskLog = $taskLog;
Expand Down
1 change: 0 additions & 1 deletion src/Normalizer/TaskDetailsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function normalizeTaskDetails (Envelope $envelope) : array

/** @phpstan-var TaskDetails $details */
$details = [
"class" => $task::class,
"transport" => $envelope->last(ReceivedStamp::class)?->getTransportName(),
"handledBy" => $envelope->last(HandledStamp::class)?->getHandlerName(),
];
Expand Down