diff --git a/src/Application/Regulation/Query/GetStatisticsQuery.php b/src/Application/Regulation/Query/GetStatisticsQuery.php deleted file mode 100644 index e6b2b588c..000000000 --- a/src/Application/Regulation/Query/GetStatisticsQuery.php +++ /dev/null @@ -1,11 +0,0 @@ -userRepository->countUsers(), - organizations: $this->organizationRepository->countOrganizations(), - totalRegulationOrderRecords: $this->regulationOrderRecordRepository->countTotalRegulationOrderRecords(), - publishedRegulationOrderRecords: $this->regulationOrderRecordRepository->countPublishedRegulationOrderRecords(), - permanentRegulationOrderRecords: $this->regulationOrderRecordRepository->countPermanentRegulationOrderRecords(), - temporaryRegulationOrderRecords: $this->regulationOrderRecordRepository->countTemporaryRegulationOrderRecords(), - ); - } -} diff --git a/src/Infrastructure/Controller/StatisticsController.php b/src/Infrastructure/Controller/StatisticsController.php index c835b13ab..7495e5fcf 100644 --- a/src/Infrastructure/Controller/StatisticsController.php +++ b/src/Infrastructure/Controller/StatisticsController.php @@ -4,8 +4,6 @@ namespace App\Infrastructure\Controller; -use App\Application\QueryBusInterface; -use App\Application\Regulation\Query\GetStatisticsQuery; use App\Infrastructure\Adapter\MetabaseEmbedFactory; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -14,7 +12,6 @@ final class StatisticsController { public function __construct( private \Twig\Environment $twig, - private QueryBusInterface $queryBus, private MetabaseEmbedFactory $metabaseEmbedFactory, ) { } @@ -22,12 +19,9 @@ public function __construct( #[Route('/stats', name: 'app_stats', methods: ['GET'])] public function __invoke(): Response { - $statistics = $this->queryBus->handle(new GetStatisticsQuery()); - $dashboardEmbedUrl = $this->metabaseEmbedFactory->makeDashboardUrl(); return new Response($this->twig->render('statistics.html.twig', [ - 'statistics' => $statistics, 'dashboardEmbedUrl' => $dashboardEmbedUrl, ])); } diff --git a/templates/statistics.html.twig b/templates/statistics.html.twig index f284d898f..0260be26d 100644 --- a/templates/statistics.html.twig +++ b/templates/statistics.html.twig @@ -8,87 +8,20 @@

{{ 'statistics.title'|trans }}

-
-
- - - -
-
- -
-
-
-
-
-

{{ 'statistics.users'|trans }}

-

{{ statistics.users }}

-
-
-
-
-
-
-
-
-

{{ 'statistics.organizations'|trans }}

-

{{ statistics.organizations }}

-
-
-
-
-
-
-
-
-

{{ 'statistics.totalRegulationOrderRecords'|trans }}

-

{{ statistics.totalRegulationOrderRecords }}

-
-
-
-
-
-
-
-
-

{{ 'statistics.publishedRegulationOrderRecords'|trans }}

-

{{ statistics.publishedRegulationOrderRecords }}

-
-
-
-
-
-
-
-
-

{{ 'statistics.permanentRegulationOrderRecords'|trans }}

-

{{ statistics.permanentRegulationOrderRecords }}

-
-
-
-
-
-
-
-
-

{{ 'statistics.temporaryRegulationOrderRecords'|trans }}

-

{{ statistics.temporaryRegulationOrderRecords }}

-
-
-
-
-
+ + +
{% endblock %} diff --git a/tests/Integration/Infrastructure/Controller/StatisticsControllerTest.php b/tests/Integration/Infrastructure/Controller/StatisticsControllerTest.php index 82dbccccf..f1605a419 100644 --- a/tests/Integration/Infrastructure/Controller/StatisticsControllerTest.php +++ b/tests/Integration/Infrastructure/Controller/StatisticsControllerTest.php @@ -16,15 +16,7 @@ public function testStatistics(): void $this->assertMetaTitle('Statistiques - DiaLog', $crawler); $this->assertSame('Statistiques', $crawler->filter('h1')->text()); - $stats = $crawler->filter('[data-testid=stat]'); - $this->assertSame(7, $stats->count()); - - $this->assertSame('Tableau de bord des indicateurs', $stats->eq(0)->attr('title')); - $this->assertSame("Nombre total d'utilisateurs 3", $stats->eq(1)->text()); - $this->assertSame("Nombre total d'organisations 2", $stats->eq(2)->text()); - $this->assertSame("Nombre total d'arrếtés 1", $stats->eq(3)->text()); - $this->assertSame("Nombre total d'arrếtés publiés 1", $stats->eq(4)->text()); - $this->assertSame("Nombre total d'arrếtés permanents 0", $stats->eq(5)->text()); - $this->assertSame("Nombre total d'arrếtés temporaires 1", $stats->eq(6)->text()); + $dashboard = $crawler->filter('[data-testid=dashboard]')->eq(0); + $this->assertSame('Tableau de bord des indicateurs', $dashboard->attr('title')); } } diff --git a/tests/Unit/Application/Regulation/Query/GetStatisticsQueryHandlerTest.php b/tests/Unit/Application/Regulation/Query/GetStatisticsQueryHandlerTest.php deleted file mode 100644 index f32d817da..000000000 --- a/tests/Unit/Application/Regulation/Query/GetStatisticsQueryHandlerTest.php +++ /dev/null @@ -1,62 +0,0 @@ -createMock(UserRepositoryInterface::class); - $organizationRepository = $this->createMock(OrganizationRepositoryInterface::class); - $regulationOrderRecordRepository = $this->createMock(RegulationOrderRecordRepositoryInterface::class); - - $userRepository - ->expects(self::once()) - ->method('countUsers') - ->willReturn(10); - $organizationRepository - ->expects(self::once()) - ->method('countOrganizations') - ->willReturn(3); - $regulationOrderRecordRepository - ->expects(self::once()) - ->method('countTotalRegulationOrderRecords') - ->willReturn(20); - $regulationOrderRecordRepository - ->expects(self::once()) - ->method('countPublishedRegulationOrderRecords') - ->willReturn(10); - $regulationOrderRecordRepository - ->expects(self::once()) - ->method('countPermanentRegulationOrderRecords') - ->willReturn(2); - $regulationOrderRecordRepository - ->expects(self::once()) - ->method('countTemporaryRegulationOrderRecords') - ->willReturn(8); - - $handler = new GetStatisticsQueryHandler($userRepository, $organizationRepository, $regulationOrderRecordRepository); - $stats = $handler(new GetStatisticsQuery()); - - $result = new StatisticsView( - users: 10, - organizations: 3, - totalRegulationOrderRecords: 20, - publishedRegulationOrderRecords: 10, - permanentRegulationOrderRecords: 2, - temporaryRegulationOrderRecords: 8, - ); - - $this->assertEquals($result, $stats); - } -}