6
6
7
7
use GraphAware \Common \Cypher \StatementInterface ;
8
8
use GraphAware \Common \Result \StatementResult as StatementResultInterface ;
9
+ use GraphAware \Common \Result \StatementStatisticsInterface ;
9
10
10
11
/**
11
12
* @author Xavier Coureau <[email protected] >
@@ -48,6 +49,7 @@ public function record(StatementInterface $statement)
48
49
'query ' => $ statementText ,
49
50
'parameters ' => $ statementParams ,
50
51
'tag ' => $ statement ->getTag (),
52
+ 'statistics ' => [],
51
53
];
52
54
$ this ->statementsHash [$ statementText ][$ statementParams ][$ tag ] = $ idx ;
53
55
}
@@ -74,6 +76,7 @@ public function finish(StatementResultInterface $statementResult)
74
76
$ this ->statements [$ idx ] = array_merge ($ this ->statements [$ idx ], [
75
77
'end_time ' => microtime (true ) * 1000 ,
76
78
'nb_results ' => $ statementResult ->size (),
79
+ 'statistics ' => $ this ->statisticsToArray ($ statementResult ->summarize ()->updateStatistics ()),
77
80
]);
78
81
}
79
82
@@ -118,4 +121,24 @@ public function getElapsedTime()
118
121
119
122
return $ time ;
120
123
}
124
+
125
+ private function statisticsToArray (StatementStatisticsInterface $ statementStatistics )
126
+ {
127
+ $ data = [
128
+ 'contains_updates ' => $ statementStatistics ->containsUpdates (),
129
+ 'nodes_created ' => $ statementStatistics ->nodesCreated (),
130
+ 'nodes_deleted ' => $ statementStatistics ->nodesDeleted (),
131
+ 'relationships_created ' => $ statementStatistics ->relationshipsCreated (),
132
+ 'relationships_deleted ' => $ statementStatistics ->relationshipsDeleted (),
133
+ 'properties_set ' => $ statementStatistics ->propertiesSet (),
134
+ 'labels_added ' => $ statementStatistics ->labelsAdded (),
135
+ 'labels_removed ' => $ statementStatistics ->labelsRemoved (),
136
+ 'indexes_added ' => $ statementStatistics ->indexesAdded (),
137
+ 'indexes_removed ' => $ statementStatistics ->indexesRemoved (),
138
+ 'constraints_added ' => $ statementStatistics ->constraintsAdded (),
139
+ 'constraints_removed ' => $ statementStatistics ->constraintsRemoved (),
140
+ ];
141
+
142
+ return $ data ;
143
+ }
121
144
}
0 commit comments