-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace App\Command\Cron\Site; | ||
|
||
use App\Repository\Reference\ProjectReferenceRepository; | ||
use App\Service\Aid\AidService; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
#[AsCommand(name: 'at:cron:site:redis_cache_reset', description: 'Vide le cache Redis')] | ||
class RedisCacheResetCommand extends Command | ||
{ | ||
public function __construct( | ||
private CacheItemPoolInterface $cache, | ||
private AidService $aidService, | ||
private ProjectReferenceRepository $projectReferenceRepository | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$this->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; | ||
} | ||
} |