• 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

3.33
/src/Repository/ValidationRepository.php
1
<?php
2

3
namespace App\Repository;
4

5
use App\Entity\Validation;
6
use DateTime;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Persistence\ManagerRegistry;
9

10
/**
11
 * @method Validation|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method Validation|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method Validation[]    findAll()
14
 * @method Validation[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class ValidationRepository extends ServiceEntityRepository
17
{
18
    public function __construct(ManagerRegistry $registry)
19
    {
20
        parent::__construct($registry, Validation::class);
20✔
21
    }
22

23
    /**
24
     * Update next "pending" validation to "processing" and returns it
25
     *
26
     * @return Validation|null
27
     */
28
    public function popNextPending()
29
    {
30
        $em = $this->getEntityManager();
×
31
        $conn = $em->getConnection();
×
32

33
        $conn->beginTransaction();
×
34
        $conn->executeQuery('LOCK TABLE validation IN ACCESS EXCLUSIVE MODE;');
×
35

36
        /** @var Validation|null $result */
37
        $result = $this->createQueryBuilder('v')
×
38
            ->where('v.status = :status')
×
39
            ->setParameters(['status' => Validation::STATUS_PENDING])
×
40
            ->orderBy('v.dateCreation', 'ASC')
×
41
            ->setMaxResults(1)
×
42
            ->getQuery()
×
43
            ->getOneOrNullResult()
×
44
        ;
×
45

46
        if (!is_null($result)) {
×
47
            $result->setStatus(Validation::STATUS_PROCESSING);
×
48
            $result->setDateStart(new \DateTime('now'));
×
49
            $em->flush($result);
×
50
            $em->refresh($result);
×
51
        }
52

53
        $conn->commit();
×
54
        return $result;
×
55
    }
56

57
    /**
58
     * Finds all archivable validations older than expiryDate.
59
     *
60
     * @param DateTime $expiryDate
61
     * @return array<Validation>
62
     */
63
    public function findAllToBeArchived(DateTime $expiryDate)
64
    {
UNCOV
65
        return $this->createQueryBuilder('v')
×
UNCOV
66
            ->where('v.dateCreation < :expiryDate')
×
UNCOV
67
            ->andWhere('v.status != :ignoredStatus')
×
UNCOV
68
            ->setParameters([
×
UNCOV
69
                'expiryDate' => $expiryDate,
×
UNCOV
70
                'ignoredStatus' => Validation::STATUS_ARCHIVED,
×
UNCOV
71
            ])
×
UNCOV
72
            ->getQuery()
×
UNCOV
73
            ->getResult()
×
UNCOV
74
        ;
×
75
    }
76
}
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