fix: address code review issues
- Rename `read` column to `is_read` (PostgreSQL reserved word) - Wrap navbar + modal in parent div for Stimulus controller scope - Set temporary filePath before first flush in ImportController - Use RETURNING clause for atomic incrementProcessedBatches - Return proper empty 204 response in NotificationController Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ class ImportController extends AbstractController
|
||||
|
||||
$import = new Import();
|
||||
$import->setUser($user);
|
||||
$import->setFilePath('pending');
|
||||
|
||||
$em->persist($import);
|
||||
$em->flush();
|
||||
|
||||
@@ -37,13 +37,13 @@ class NotificationController extends AbstractController
|
||||
|
||||
#[Route('/api/notifications/read', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_USER')]
|
||||
public function markRead(NotificationRepository $notificationRepository): JsonResponse
|
||||
public function markRead(NotificationRepository $notificationRepository): Response
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
$notificationRepository->markAllReadForUser($user);
|
||||
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
return new Response('', Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Notification
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $message = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[ORM\Column(name: 'is_read')]
|
||||
private bool $read = false;
|
||||
|
||||
#[ORM\Column]
|
||||
|
||||
@@ -20,13 +20,8 @@ class ImportRepository extends ServiceEntityRepository
|
||||
|
||||
public function incrementProcessedBatches(Import $import): int
|
||||
{
|
||||
$this->getEntityManager()->getConnection()->executeStatement(
|
||||
'UPDATE import SET processed_batches = processed_batches + 1 WHERE id = :id',
|
||||
['id' => $import->getId()]
|
||||
);
|
||||
|
||||
return (int) $this->getEntityManager()->getConnection()->fetchOne(
|
||||
'SELECT processed_batches FROM import WHERE id = :id',
|
||||
'UPDATE import SET processed_batches = processed_batches + 1 WHERE id = :id RETURNING processed_batches',
|
||||
['id' => $import->getId()]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user