66
77use GraphAware \Common \Cypher \StatementInterface ;
88use GraphAware \Common \Result \StatementResult as StatementResultInterface ;
9+ use GraphAware \Common \Result \StatementStatistics ;
10+ use GraphAware \Common \Result \StatementStatisticsInterface ;
911
1012/**
1113 * @author Xavier Coureau <[email protected] > @@ -48,6 +50,7 @@ public function record(StatementInterface $statement)
4850 'query ' => $ statementText ,
4951 'parameters ' => $ statementParams ,
5052 'tag ' => $ statement ->getTag (),
53+ 'statistics ' => []
5154 ];
5255 $ this ->statementsHash [$ statementText ][$ statementParams ][$ tag ] = $ idx ;
5356 }
@@ -74,6 +77,7 @@ public function finish(StatementResultInterface $statementResult)
7477 $ this ->statements [$ idx ] = array_merge ($ this ->statements [$ idx ], [
7578 'end_time ' => microtime (true ) * 1000 ,
7679 'nb_results ' => $ statementResult ->size (),
80+ 'statistics ' => $ this ->statisticsToArray ($ statementResult ->summarize ()->updateStatistics ())
7781 ]);
7882 }
7983
@@ -118,4 +122,24 @@ public function getElapsedTime()
118122
119123 return $ time ;
120124 }
125+
126+ private function statisticsToArray (StatementStatisticsInterface $ statementStatistics )
127+ {
128+ $ data = [
129+ 'contains_updates ' => $ statementStatistics ->containsUpdates (),
130+ 'nodes_created ' => $ statementStatistics ->nodesCreated (),
131+ 'nodes_deleted ' => $ statementStatistics ->nodesDeleted (),
132+ 'relationships_created ' => $ statementStatistics ->relationshipsCreated (),
133+ 'relationships_deleted ' => $ statementStatistics ->relationshipsDeleted (),
134+ 'properties_set ' => $ statementStatistics ->propertiesSet (),
135+ 'labels_added ' => $ statementStatistics ->labelsAdded (),
136+ 'labels_removed ' => $ statementStatistics ->labelsRemoved (),
137+ 'indexes_added ' => $ statementStatistics ->indexesAdded (),
138+ 'indexes_removed ' => $ statementStatistics ->indexesRemoved (),
139+ 'constraints_added ' => $ statementStatistics ->constraintsAdded (),
140+ 'constraints_removed ' => $ statementStatistics ->constraintsRemoved ()
141+ ];
142+
143+ return $ data ;
144+ }
121145}
0 commit comments