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

tomasnorre / crawler / 18655733636

20 Oct 2025 02:45PM UTC coverage: 68.73% (-1.0%) from 69.702%
18655733636

Pull #1205

github

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

0 of 39 new or added lines in 2 files covered. (0.0%)

1921 of 2795 relevant lines covered (68.73%)

3.22 hits per line

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

0.0
/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\Model\Process;
23
use AOE\Crawler\Domain\Repository\ProcessRepository;
24
use Psr\Http\Message\ResponseInterface;
25
use Psr\Http\Message\ServerRequestInterface;
26
use TYPO3\CMS\Core\Http\Response;
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28

29
class ProcessStatusController
30
{
31
    public function getProcessStatus(ServerRequestInterface $request): ResponseInterface
32
    {
NEW
33
        $body = $request->getBody()->getContents();
×
NEW
34
        $data = json_decode($body, true);
×
NEW
35
        $id = $data['id'] ?? null;
×
36

NEW
37
        $response = new Response();
×
38

NEW
39
        if ($id === null) {
×
NEW
40
            return $response->withStatus(400, 'No process ID provided');
×
41
        }
42

NEW
43
        $process = $this->getProcess($id);
×
NEW
44
        if ($process === null) {
×
NEW
45
            return $response->withStatus(404, 'Process with ID ' . $id . ' not found');
×
46
        }
47

NEW
48
        $content = json_encode(
×
NEW
49
            [
×
NEW
50
                'status' => $process->getProgress(),
×
NEW
51
                'procesedItems' => $process->getAmountOfItemsProcessed(),
×
NEW
52
                'processId' => $id,
×
NEW
53
            ]
×
NEW
54
        );
×
NEW
55
        if ($content === false) {
×
NEW
56
            throw new \RuntimeException('Failed to encode JSON response', 1760971184);
×
57
        }
NEW
58
        $response->getBody()->write($content);
×
NEW
59
        return $response;
×
60
    }
61

62
    private function getProcess(string $id): ?Process
63
    {
NEW
64
        $processRepository = GeneralUtility::makeInstance(ProcessRepository::class);
×
NEW
65
        return $processRepository->findByProcessId($id);
×
66
    }
67
}
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