Skip to content

Commit 41fa5b1

Browse files
committed
fixed summary handling
1 parent 2fff1fd commit 41fa5b1

File tree

2 files changed

+38
-33
lines changed

2 files changed

+38
-33
lines changed

src/Formatter/SummarizedResultFormatter.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ public function __construct(OGMFormatter $formatter)
7272
*/
7373
public function formatHttpStats(stdClass $response, ConnectionInterface $connection, Statement $statement, float $resultAvailableAfter, float $resultConsumedAfter, CypherList $results): SummarizedResult
7474
{
75-
if (!isset($response->stats)) {
75+
if ($response->summary instanceof stdClass) {
76+
/** @var stdClass $stats */
77+
$stats = $response->summary->stats;
78+
} elseif (!isset($response->stats)) {
79+
/** @var stdClass $stats */
80+
$stats = $response->stats;
81+
} else {
7682
throw new UnexpectedValueException('No stats found in the response set');
7783
}
7884

@@ -81,20 +87,20 @@ public function formatHttpStats(stdClass $response, ConnectionInterface $connect
8187
* @psalm-suppress MixedArgument
8288
*/
8389
$counters = new SummaryCounters(
84-
$response->stats->nodes_created ?? 0,
85-
$response->stats->nodes_deleted ?? 0,
86-
$response->stats->relationships_created ?? 0,
87-
$response->stats->relationships_deleted ?? 0,
88-
$response->stats->properties_set ?? 0,
89-
$response->stats->labels_added ?? 0,
90-
$response->stats->labels_removed ?? 0,
91-
$response->stats->indexes_added ?? 0,
92-
$response->stats->indexes_removed ?? 0,
93-
$response->stats->constraints_added ?? 0,
94-
$response->stats->constraints_removed ?? 0,
95-
$response->stats->contains_updates ?? false,
96-
$response->stats->contains_system_updates ?? false,
97-
$response->stats->system_updates ?? 0,
90+
$stats->nodes_created ?? 0,
91+
$stats->nodes_deleted ?? 0,
92+
$stats->relationships_created ?? 0,
93+
$stats->relationships_deleted ?? 0,
94+
$stats->properties_set ?? 0,
95+
$stats->labels_added ?? 0,
96+
$stats->labels_removed ?? 0,
97+
$stats->indexes_added ?? 0,
98+
$stats->indexes_removed ?? 0,
99+
$stats->constraints_added ?? 0,
100+
$stats->constraints_removed ?? 0,
101+
$stats->contains_updates ?? false,
102+
$stats->contains_system_updates ?? false,
103+
$stats->system_updates ?? 0,
98104
);
99105

100106
$summary = new ResultSummary(

src/Http/HttpSession.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Laudis\Neo4j\Http;
1515

16+
use function is_object;
1617
use JsonException;
1718
use Laudis\Neo4j\Common\Resolvable;
1819
use Laudis\Neo4j\Common\TransactionHelper;
@@ -26,14 +27,13 @@
2627
use Laudis\Neo4j\Databags\TransactionConfiguration;
2728
use Laudis\Neo4j\Enum\AccessMode;
2829
use Laudis\Neo4j\Types\CypherList;
30+
use function microtime;
31+
use function parse_url;
32+
use const PHP_URL_PATH;
2933
use Psr\Http\Client\ClientInterface;
3034
use Psr\Http\Message\RequestInterface;
3135
use Psr\Http\Message\StreamFactoryInterface;
3236
use stdClass;
33-
use function is_object;
34-
use function microtime;
35-
use function parse_url;
36-
use const PHP_URL_PATH;
3737

3838
/**
3939
* @template T
@@ -78,22 +78,21 @@ final class HttpSession implements SessionInterface
7878
/**
7979
* @psalm-mutation-free
8080
*
81-
* @param FormatterInterface<T> $formatter
81+
* @param FormatterInterface<T> $formatter
8282
* @param Resolvable<StreamFactoryInterface> $factory
83-
* @param Resolvable<string> $uri
84-
* @param Resolvable<RequestFactory> $requestFactory
83+
* @param Resolvable<string> $uri
84+
* @param Resolvable<RequestFactory> $requestFactory
8585
*/
8686
public function __construct(
87-
Resolvable $factory,
88-
HttpConnectionPool $manager,
89-
SessionConfiguration $config,
90-
FormatterInterface $formatter,
91-
Resolvable $requestFactory,
92-
Resolvable $uri,
87+
Resolvable $factory,
88+
HttpConnectionPool $manager,
89+
SessionConfiguration $config,
90+
FormatterInterface $formatter,
91+
Resolvable $requestFactory,
92+
Resolvable $uri,
9393
AuthenticateInterface $auth,
94-
string $userAgent
95-
)
96-
{
94+
string $userAgent
95+
) {
9796
$this->streamFactory = $factory;
9897
$this->config = $config;
9998
$this->pool = $manager;
@@ -134,7 +133,7 @@ public function openTransaction(iterable $statements = null, ?TransactionConfigu
134133

135134
public function writeTransaction(callable $tsxHandler, ?TransactionConfiguration $config = null)
136135
{
137-
return TransactionHelper::retry(fn() => $this->openTransaction(), $tsxHandler);
136+
return TransactionHelper::retry(fn () => $this->openTransaction(), $tsxHandler);
138137
}
139138

140139
public function readTransaction(callable $tsxHandler, ?TransactionConfiguration $config = null)
@@ -213,7 +212,7 @@ private function makeTransaction(ConnectionInterface $connection, RequestInterfa
213212

214213
private function instantCommitRequest(RequestInterface $request): RequestInterface
215214
{
216-
$path = $request->getUri()->getPath() . '/commit';
215+
$path = $request->getUri()->getPath().'/commit';
217216
$uri = $request->getUri()->withPath($path);
218217

219218
return $request->withUri($uri);

0 commit comments

Comments
 (0)