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

IGNF / validator-api / 15188458321

22 May 2025 01:53PM UTC coverage: 53.006% (+19.6%) from 33.386%
15188458321

push

github

web-flow
fix: change storage location based on environmental variable

Storage adapter

11 of 28 new or added lines in 4 files covered. (39.29%)

335 of 632 relevant lines covered (53.01%)

2.78 hits per line

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

0.0
/src/Controller/Api/HealthController.php
1
<?php
2

3
namespace App\Controller\Api;
4

5
use App\Storage\ValidationsStorage;
6
use Exception;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\Routing\Annotation\Route;
9
use Doctrine\ORM\EntityManager;
10
use Doctrine\ORM\EntityManagerInterface;
11
use Symfony\Component\HttpFoundation\JsonResponse;
12
use Symfony\Component\HttpFoundation\Response;
13
use League\Flysystem\FilesystemOperator;
14
use Psr\Log\LoggerInterface;
15

16
/**
17
 * @Route("/health")
18
 */
19
class HealthController extends AbstractController
20
{
21
    public function __construct(
22
        private LoggerInterface $logger,
23
        private ValidationsStorage $storage){
24

25
    }
×
26

27
    /**
28
     * Checks for Database connection
29
     *
30
     * @Route("/db", name="health_db")
31
     */
32
    public function healthDB(EntityManagerInterface $entityManager)
33
    {
34
        $sql = "SELECT postgis_version() as postgis_version";
×
35
        $this->logger->info('get postgis version',[
×
36
            'sql' => $sql
×
37
        ]);
×
38
        try{
39
            $stmt = $entityManager->getConnection()->prepare($sql);
×
40
            $result = $stmt->executeQuery();
×
41
            return new JsonResponse($result->fetchOne(), Response::HTTP_OK);
×
42
        } catch (Exception $e){
×
43
            $this->logger->error((string) $e);
×
44
            return new JsonResponse($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
×
45
        }
46
    }
47

48
    /**
49
     * Checks for S3 connection
50
     *
51
     * @Route("/s3", name="health_s3")
52
     */
53
    public function healthS3()
54
    {
55
        $this->logger->info('list files from S3 bucket...');
×
56
        try {
NEW
57
            $files = $this->storage->getStorage()->listContents('.', false);
×
58
            $numFiles = count($files->toArray());
×
59
            return new JsonResponse('found '.$numFiles.' files', Response::HTTP_OK);
×
60
        } catch (Exception $e) {
×
61
            $this->logger->error((string) $e);
×
62
            return new JsonResponse("fail to list files from S3 bucket", Response::HTTP_INTERNAL_SERVER_ERROR);
×
63
        }
64
    }
65

66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc