diff --git a/composer.json b/composer.json index 4ba1758c..46e19a24 100755 --- a/composer.json +++ b/composer.json @@ -150,7 +150,8 @@ "php bin/console lexik:jwt:generate-keypair", "php bin/console lexik:jwt:check-config", "rm docker-compose.yml", - "rm -rf .docker" + "rm -rf .docker", + "php bin/console at:cron:site:redis_cache_reset" ], "php-config": [ "memory_limit=512M", diff --git a/cron.json b/cron.json index d30b52f9..6e0da0cf 100644 --- a/cron.json +++ b/cron.json @@ -1,7 +1,7 @@ { "jobs": [ { - "command": "45 2 * * * php bin/console at:cron:site:cache_clear" + "command": "45 2 * * * php bin/console at:cron:site:redis_cache_reset" }, { "command": "0 3 * * * php bin/console at:cron:site:datas" diff --git a/src/Command/Cron/Site/ClearCacheCommand.php b/src/Command/Cron/Site/ClearCacheCommand.php deleted file mode 100644 index 61760035..00000000 --- a/src/Command/Cron/Site/ClearCacheCommand.php +++ /dev/null @@ -1,27 +0,0 @@ -cache->clear(); - $output->writeln('Cache vidé avec succès'); - - return Command::SUCCESS; - } -} diff --git a/src/Command/Cron/Site/RedisCacheResetCommand.php b/src/Command/Cron/Site/RedisCacheResetCommand.php new file mode 100644 index 00000000..bab44e0f --- /dev/null +++ b/src/Command/Cron/Site/RedisCacheResetCommand.php @@ -0,0 +1,69 @@ +cache->clear(); + $output->writeln('Cache vidé avec succès'); + + $aidParams = [ + 'showInSearch' => true, + ]; + + $projectReferences = $this->projectReferenceRepository->findAll(); + + // on parcours les projets référents pour préparer le cache + foreach ($projectReferences as $projectReference) { + $this->aidService->searchAidsV3( + array_merge( + $aidParams, + [ + 'keyword' => $projectReference->getName(), + 'orderBy' => [ + 'sort' => 'score_total', + 'order' => 'DESC' + ], + 'projectReference' => $projectReference + ], + ) + ); + $output->writeln('Cache '.$projectReference->getName().' préparé'); + } + + // préparation du cache sans filtres + $this->aidService->searchAidsV3( + array_merge( + $aidParams, + [ + 'orderBy' => [ + 'sort' => 'score_total', + 'order' => 'DESC' + ] + ], + ) + ); + $output->writeln('Cache sans params préparé'); + + return Command::SUCCESS; + } +}