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

tomasnorre / crawler / 18658382045

20 Oct 2025 04:24PM UTC coverage: 69.396% (-0.3%) from 69.702%
18658382045

Pull #1205

github

web-flow
Merge 25db15c7c into 5745fd891
Pull Request #1205: [FEATURE] Automatic reload process status without page reload

20 of 40 new or added lines in 2 files covered. (50.0%)

1941 of 2797 relevant lines covered (69.4%)

3.23 hits per line

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

45.83
/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
    }
2✔
33

34
    public function getProcessStatus(ServerRequestInterface $request): ResponseInterface
35
    {
36
        $response = new Response();
2✔
37
        $body = $request->getParsedBody();
2✔
38
        if(!is_array($body)) {
2✔
NEW
39
            return $response->withStatus(400, 'Bad Request');
×
40
        }
41
        $id = $body['id'] ?? null;
2✔
42

43
        $response = new Response();
2✔
44

45
        if ($id === null) {
2✔
46
            return $response->withStatus(400, 'No process ID provided');
1✔
47
        }
48

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

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