-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathstatistics.ts
68 lines (55 loc) · 1.28 KB
/
statistics.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Label } from "./label";
export class Statistics {
private _raw: any
private _statistics: any
constructor(raw: any) {
this._raw = raw;
}
getStringValue(label: string) {
return this.getStatistics()[label];
}
/**
* Return the query statistics
*
* @return statistics object
*/
getStatistics() {
if (!this._statistics) {
this._statistics = {};
for (let row of this._raw) {
let touple = row.split(":");
this._statistics[touple[0]] = touple[1].trim();
}
}
return this._statistics;
}
getIntValue(label: string) {
let value = this.getStringValue(label);
return value ? parseInt(value) : 0;
}
getFloatValue(label: string) {
let value = this.getStringValue(label);
return value ? parseFloat(value) : 0;
}
nodesCreated() {
return this.getIntValue(Label.NODES_CREATED);
}
nodesDeleted() {
return this.getIntValue(Label.NODES_DELETED);
}
labelsAdded() {
return this.getIntValue(Label.LABELS_ADDED);
}
relationshipsDeleted() {
return this.getIntValue(Label.RELATIONSHIPS_DELETED);
}
relationshipsCreated() {
return this.getIntValue(Label.RELATIONSHIPS_CREATED);
}
propertiesSet() {
return this.getIntValue(Label.PROPERTIES_SET);
}
queryExecutionTime() {
return this.getFloatValue(Label.QUERY_INTERNAL_EXECUTION_TIME);
}
}