Skip to content

Commit

Permalink
change cache stats on home #3711
Browse files Browse the repository at this point in the history
  • Loading branch information
emilschn committed Feb 14, 2025
1 parent e0817e8 commit 0be7383
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Controller/HomepageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,25 @@ public function index(
SignalementRepository $signalementRepository,
PostalCodeHomeChecker $postalCodeHomeChecker,
): Response {
$stats = ['pris_en_compte' => 0, 'clotures' => 0];
$stats['total'] = $this->cache->get('homepage.stats.total', function (ItemInterface $item) use ($signalementRepository) {
$stats = $this->cache->get('homepage.stats.array', function (ItemInterface $item) use ($signalementRepository) {
$item->expiresAfter(900);

return $signalementRepository->countAll(
$stats = ['pris_en_compte' => 0, 'clotures' => 0];
$stats['total'] = $signalementRepository->countAll(
territory: null,
partners: null,
removeImported: true,
removeArchived: true
);

if ($stats['total'] > 0) {
$stats['pris_en_compte'] = round($signalementRepository->countValidated(true) / $stats['total'] * 100, 1);
$stats['clotures'] = round($signalementRepository->countClosed(true) / $stats['total'] * 100, 1);
}

return $stats;
});

if ($stats['total'] > 0) {
$stats['pris_en_compte'] = round($signalementRepository->countValidated(true) / $stats['total'] * 100, 1);
$stats['clotures'] = round($signalementRepository->countClosed(true) / $stats['total'] * 100, 1);
}

$displayModal = '';

Expand Down

0 comments on commit 0be7383

Please sign in to comment.