Skip to content

Commit

Permalink
ApiCallMonitor::getProcessMonitor getter + start and end method adjus…
Browse files Browse the repository at this point in the history
…tement
  • Loading branch information
mathieu-ducrot committed Jun 5, 2024
1 parent 2a0e49c commit 94178df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
CHANGELOG for 1.x
===================
## v1.4.2 - (2024-06-05)
### Added
- `ApiCallMonitor::getProcessMonitor` getter to access the ProcessMonitor instance through it

### Changed
- `ApiCallMonitor::start` add **$flush** param to match `ProcessMonitor::start` definition
- `ApiCallMonitor::end` use Symfony Response const instead of hard coded value for the isSuccess check, also expand the range to >= 100 and < 400

### Fixed
- `GroupConcat` remove @phpstan-ignore-line false positive

## v1.4.1 - (2024-05-29)
### Fixed
- `DateUtils::millisecondsToString` int type cast when calling **secondsToString** to fix the deprecated: Implicit conversion from float
Expand Down
13 changes: 9 additions & 4 deletions src/Monitoring/ApiCallMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Smart\CoreBundle\Monitoring;

use Smart\CoreBundle\Entity\ApiCallInterface;
use Smart\CoreBundle\Entity\ProcessInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @author Mathieu Ducrot <[email protected]>
Expand All @@ -15,9 +15,9 @@ public function __construct(private readonly ProcessMonitor $processMonitor)
{
}

public function start(ApiCallInterface $apiCall, Request $request): ApiCallInterface
public function start(ApiCallInterface $apiCall, Request $request, bool $flush = false): ApiCallInterface
{
$this->processMonitor->start($apiCall);
$this->processMonitor->start($apiCall, $flush);
$apiCall->setMethod($request->getMethod());
$apiCall->setRouteUrl($request->getUri());
$apiCall->setType($request->attributes->get('_route'));
Expand All @@ -29,6 +29,11 @@ public function start(ApiCallInterface $apiCall, Request $request): ApiCallInter
public function end(ApiCallInterface $apiCall, int $statusCode, bool $flush = true): void
{
$apiCall->setStatusCode($statusCode);
$this->processMonitor->end($apiCall, $statusCode >= 200 && $statusCode < 300, $flush);
$this->processMonitor->end($apiCall, $statusCode >= Response::HTTP_CONTINUE && $statusCode < Response::HTTP_BAD_REQUEST, $flush);
}

public function getProcessMonitor(): ProcessMonitor
{
return $this->processMonitor;
}
}
2 changes: 1 addition & 1 deletion src/Query/MySQL/GroupConcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
}

if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) {
if (strtolower($lexer->lookahead['value']) !== 'separator') { // @phpstan-ignore-line
if (strtolower($lexer->lookahead['value']) !== 'separator') {

Check failure on line 57 in src/Query/MySQL/GroupConcat.php

View workflow job for this annotation

GitHub Actions / ci

Cannot access offset 'value' on Doctrine\Common\Lexer\Token<1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|100|101|102|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255|256, string>.
$parser->syntaxError('separator');
}
$parser->match(Lexer::T_IDENTIFIER);
Expand Down

0 comments on commit 94178df

Please sign in to comment.