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

tomasnorre / crawler / 18706668671

22 Oct 2025 05:48AM UTC coverage: 69.481% (-0.2%) from 69.702%
18706668671

push

github

web-flow
[FEATURE] Automatic reload process status without page reload (#1205)

21 of 39 new or added lines in 2 files covered. (53.85%)

1942 of 2795 relevant lines covered (69.48%)

3.24 hits per line

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

95.45
/Classes/Controller/Ajax/ProcessStatusController.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * (c) 2025 Tomas Norre Mikkelsen <tomasnorre@gmail.com>
7
 *
8
 * This file is part of the TYPO3 Crawler Extension.
9
 *
10
 * It is free software; you can redistribute it and/or modify it under
11
 * the terms of the GNU General Public License, either version 2
12
 * of the License, or any later version.
13
 *
14
 * For the full copyright and license information, please read the
15
 * LICENSE.txt file that was distributed with this source code.
16
 *
17
 * The TYPO3 project - inspiring people to share!
18
 */
19

20
namespace AOE\Crawler\Controller\Ajax;
21

22
use AOE\Crawler\Domain\Repository\ProcessRepository;
23
use Psr\Http\Message\ResponseInterface;
24
use Psr\Http\Message\ServerRequestInterface;
25
use TYPO3\CMS\Core\Http\Response;
26

27
class ProcessStatusController
28
{
29
    public function __construct(
30
        private readonly ProcessRepository $processRepository,
31
    ) {
32
    }
3✔
33

34
    public function getProcessStatus(ServerRequestInterface $request): ResponseInterface
35
    {
36
        $body = $request->getBody()->getContents();
3✔
37
        $data = json_decode($body, true);
3✔
38
        $id = $data['id'] ?? null;
3✔
39

40
        $response = new Response();
3✔
41

42
        if ($id === null) {
3✔
43
            return $response->withStatus(400, 'No process ID provided');
1✔
44
        }
45

46
        $process = $this->processRepository->findByProcessId($id);
2✔
47
        if ($process === null) {
2✔
48
            return $response->withStatus(404, 'Process with ID: ' . $id . ' not found');
1✔
49
        }
50

51
        $content = json_encode(
1✔
52
            [
1✔
53
                'status' => $process->getProgress(),
1✔
54
                'processedItems' => $process->getAmountOfItemsProcessed(),
1✔
55
                'runtime' => $process->getRuntime(),
1✔
56
                'processId' => $process->getProcessId(),
1✔
57
            ]
1✔
58
        );
1✔
59
        if ($content === false) {
1✔
NEW
60
            throw new \RuntimeException('Failed to encode JSON response', 1760971184);
×
61
        }
62
        $response->getBody()->write($content);
1✔
63
        return $response;
1✔
64
    }
65
}
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