@@ -25,19 +25,23 @@ class MethodUsagePage extends BasePage
25
25
protected $ MethodData ;
26
26
/** @var FieldList */
27
27
protected $ FieldList ;
28
+ /** @var bool */
29
+ protected $ use_method_usage_optimisation = false ;
28
30
29
31
public function __construct (
30
32
View $ View ,
31
33
SnapshotInterface $ Snapshot ,
32
34
MethodInterface $ Method ,
33
35
MethodDataInterface $ MethodData ,
34
- FieldList $ FieldList
36
+ FieldList $ FieldList ,
37
+ bool $ use_method_usage_optimisation = false
35
38
) {
36
39
$ this ->View = $ View ;
37
40
$ this ->Snapshot = $ Snapshot ;
38
41
$ this ->Method = $ Method ;
39
42
$ this ->MethodData = $ MethodData ;
40
43
$ this ->FieldList = $ FieldList ;
44
+ $ this ->use_method_usage_optimisation = $ use_method_usage_optimisation ;
41
45
}
42
46
43
47
protected function cleanData () : bool
@@ -73,10 +77,19 @@ public function getTemplateData() : array
73
77
74
78
$ results = [];
75
79
if (!empty ($ methods )) {
80
+ $ start_snapshot_id = 0 ;
81
+ if ($ this ->use_method_usage_optimisation ) {
82
+ $ last_two_days = \Badoo \LiveProfilerUI \DateGenerator::getDatesArray (date ('Y-m-d ' ), 2 , 2 );
83
+ $ start_snapshot_id = in_array (current ($ methods )['date ' ], $ last_two_days , true )
84
+ ? $ this ->Snapshot ->getMinSnapshotIdByDates ($ last_two_days )
85
+ : 0 ;
86
+ }
87
+
76
88
$ method_data = $ this ->MethodData ->getDataByMethodIdsAndSnapshotIds (
77
89
[],
78
90
array_keys ($ methods ),
79
- 100
91
+ 200 ,
92
+ $ start_snapshot_id
80
93
);
81
94
82
95
$ snapshot_ids = [];
@@ -97,6 +110,7 @@ public function getTemplateData() : array
97
110
foreach ($ fields as $ field ) {
98
111
$ result ['fields ' ][$ field ] = $ values [$ field ];
99
112
}
113
+ $ result ['fields ' ]['calls_count ' ] = $ snapshots [$ Row ->getSnapshotId ()]['calls_count ' ];
100
114
$ results [] = $ result ;
101
115
}
102
116
}
0 commit comments