@@ -62,32 +62,34 @@ public function getTemplateData() : array
6262 $ error = 'Enter method name ' ;
6363 }
6464
65- $ methods = [];
65+ $ method = [];
6666 if (!$ error ) {
6767 $ this ->data ['method ' ] = ltrim ($ this ->data ['method ' ], '\\' );
6868 $ methods = $ this ->Method ->findByName ($ this ->data ['method ' ], true );
6969
7070 if (empty ($ methods )) {
7171 $ error = 'Method " ' . $ this ->data ['method ' ] . '" not found ' ;
72+ } else {
73+ $ method = current ($ methods );
7274 }
7375 }
7476
7577 $ fields = $ this ->FieldList ->getFields ();
7678 $ field_descriptions = $ this ->FieldList ->getFieldDescriptions ();
7779
7880 $ results = [];
79- if (!empty ($ methods )) {
81+ if (!empty ($ method )) {
8082 $ start_snapshot_id = 0 ;
8183 if ($ this ->use_method_usage_optimisation ) {
8284 $ 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 )
85+ $ start_snapshot_id = in_array ($ method ['date ' ], $ last_two_days , true )
8486 ? $ this ->Snapshot ->getMinSnapshotIdByDates ($ last_two_days )
8587 : 0 ;
8688 }
8789
8890 $ method_data = $ this ->MethodData ->getDataByMethodIdsAndSnapshotIds (
8991 [],
90- array_keys ( $ methods ) ,
92+ [ $ method [ ' id ' ]] ,
9193 200 ,
9294 $ start_snapshot_id
9395 );
@@ -113,10 +115,13 @@ public function getTemplateData() : array
113115 $ result ['fields ' ]['calls_count ' ] = $ snapshots [$ Row ->getSnapshotId ()]['calls_count ' ];
114116 $ results [] = $ result ;
115117 }
118+
119+ if (empty ($ results )) {
120+ $ error = 'There is no result for ' . $ this ->data ['method ' ] . '. Last time it was called on ' . $ method ['date ' ] . '. ' ;
121+ }
116122 }
117123
118124 return [
119- 'methods ' => $ methods ,
120125 'method ' => $ this ->data ['method ' ],
121126 'results ' => $ results ,
122127 'field_descriptions ' => $ field_descriptions ,
0 commit comments