refs #2630. Create service MarkTracesAssSuccess
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
8a8f67b776
commit
c89062375b
|
@ -41,6 +41,15 @@ resources:
|
|||
input: App\Dto\Input\KillJobInput
|
||||
uriTemplate: /traces/{uuid}/kill-job
|
||||
|
||||
mark_traces_as_success:
|
||||
shortName: Mark Trace as Success
|
||||
description: Mark a single trace as successfully completed
|
||||
controller: App\Controller\MarkTracesAsSuccessAction
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: false
|
||||
uriTemplate: /traces/{uuid}/mark-as-success
|
||||
|
||||
order:
|
||||
createdAt: DESC
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Trace;
|
||||
use App\Model\TraceStatus;
|
||||
use App\Repository\TraceRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
|
||||
|
||||
class MarkTracesAsSuccessAction extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly TraceRepository $traceRepository,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(string $uuid): JsonResponse
|
||||
{
|
||||
$trace = $this->traceRepository->findOneBy(['uuid' => $uuid]);
|
||||
|
||||
if (!$trace) {
|
||||
return new JsonResponse(data: 'Trace not found', status: Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setOutput('Trace marked as success manually');
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
|
||||
$this->entityManager->persist($trace);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(data: 'Trace marked as success successfully', status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ class Image extends AbstractEntity
|
|||
private ?self $parent = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn( onDelete: 'SET NULL')]
|
||||
private ?Client $client = null;
|
||||
|
||||
#[ORM\Column]
|
||||
|
|
Loading…
Reference in New Issue