• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IGNF / validator-api / 14596906002

22 Apr 2025 02:09PM UTC coverage: 33.386% (-12.1%) from 45.455%
14596906002

push

github

web-flow
Merge pull request #78 from IGNF/fix_timeout_error

Fix timeout error

0 of 61 new or added lines in 3 files covered. (0.0%)

72 existing lines in 5 files now uncovered.

210 of 629 relevant lines covered (33.39%)

2.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Command/Validations/CleanupCommand.php
1
<?php
2

3
namespace App\Command\Validations;
4

5
use App\Entity\Validation;
6
use App\Repository\ValidationRepository;
7
use App\Validation\ValidationManager;
8
use Doctrine\ORM\EntityManagerInterface;
9
use Psr\Log\LoggerInterface;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Input\InputOption;
13
use Symfony\Component\Console\Output\OutputInterface;
14

15
/**
16
 * Helper command to archive old validations removing files.
17
 */
18
class CleanupCommand extends Command
19
{
20
    protected static $defaultName = 'ign-validator:validations:cleanup';
21

22
    /**
23
     * Time interval of 30 days
24
     */
25
    const DEFAULT_EXPIRY_CONDITION = 'P1M';
26

27
    /**
28
     * @var EntityManagerInterface
29
     */
30
    private $em;
31

32
    /**
33
     * @var ValidationManager
34
     */
35
    private $validationManager;
36

37
    /**
38
     * @var LoggerInterface
39
     */
40
    private $logger;
41

42
    public function __construct(
43
        EntityManagerInterface $em,
44
        ValidationManager $validationManager,
45
        LoggerInterface $logger
46
    ) {
UNCOV
47
        parent::__construct();
×
UNCOV
48
        $this->em = $em;
×
UNCOV
49
        $this->validationManager = $validationManager;
×
UNCOV
50
        $this->logger = $logger;
×
51
    }
52

53
    protected function configure()
54
    {
UNCOV
55
        $this
×
UNCOV
56
            ->setDescription('Deletes all validation files that are older than max-age (default 1 month)')
×
UNCOV
57
            ->addOption(
×
UNCOV
58
                'max-age',
×
UNCOV
59
                null,
×
UNCOV
60
                InputOption::VALUE_REQUIRED,
×
UNCOV
61
                'Max duration to keep validation files (P1M : 1 month, PT30M : 30 minutes,...)',
×
UNCOV
62
                self::DEFAULT_EXPIRY_CONDITION
×
UNCOV
63
            );
×
64
    }
65

66
    /**
67
     * {@inheritdoc}
68
     */
69
    protected function execute(InputInterface $input, OutputInterface $output): int
70
    {
UNCOV
71
        $maxAge = $input->getOption('max-age');
×
UNCOV
72
        $today = new \DateTime('now');
×
UNCOV
73
        $dateExpire = $today->sub(new \DateInterval($maxAge));
×
74

UNCOV
75
        $this->logger->info('archive validations older than {$maxAge}...', [
×
UNCOV
76
            '$maxAge' => $maxAge
×
UNCOV
77
        ]);
×
UNCOV
78
        $validations = $this->getValidationRepository()->findAllToBeArchived($dateExpire);
×
UNCOV
79
        $count = 0;
×
UNCOV
80
        foreach ($validations as $validation) {
×
UNCOV
81
            $this->validationManager->archive($validation);
×
UNCOV
82
            $count++;
×
83
        }
UNCOV
84
        $this->logger->info('archive validations older than {maxTime} : completed, {count} validation(s) processed.', [
×
UNCOV
85
            'maxTime' => $maxAge,
×
UNCOV
86
            'count' => $count
×
UNCOV
87
        ]);
×
UNCOV
88
        return 0;
×
89
    }
90

91
    /**
92
     * @return ValidationRepository
93
     */
94
    protected function getValidationRepository()
95
    {
UNCOV
96
        return $this->em->getRepository(Validation::class);
×
97
    }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc