Skip to content

Commit 0523e8c

Browse files
committed
added /profiler/all-methods.json
1 parent 8032f77 commit 0523e8c

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
There are next changes:
66

7+
## 1.2.12
8+
9+
There are next changes:
10+
11+
- added a method to return all saved methods
12+
713
## 1.2.11
814

915
There are next changes:

src/Badoo/LiveProfilerUI/DataProviders/Interfaces/MethodInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
interface MethodInterface
1010
{
1111
public function findByName(string $method_name, bool $strict = false) : array;
12+
public function all() : array;
1213
public function getListByNames(array $names) : array;
1314
public function getListByIds(array $ids) : array;
1415
public function insertMany(array $inserts) : bool;

src/Badoo/LiveProfilerUI/DataProviders/Method.php

+17
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ public function findByName(string $method_name, bool $strict = false) : array
4242
return $methods;
4343
}
4444

45+
public function all() : array
46+
{
47+
$result = $this->AggregatorStorage->getAll(
48+
self::TABLE_NAME,
49+
['all'],
50+
[]
51+
);
52+
$methods = [];
53+
if (!empty($result)) {
54+
foreach ($result as $row) {
55+
$methods[$row['id']] = $row;
56+
}
57+
}
58+
59+
return $methods;
60+
}
61+
4562
public function getListByNames(array $names) : array
4663
{
4764
if (empty($names)) {

src/Badoo/LiveProfilerUI/Pages/AjaxPages.php

+16
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ public function searchMethods(string $term) : array
160160
}
161161
}
162162

163+
public function allMethods() : array
164+
{
165+
try {
166+
$methods = $this->Method->all();
167+
168+
$result = [];
169+
foreach ($methods as $method) {
170+
$result[$method['name']] = $method['date'];
171+
}
172+
173+
return $result;
174+
} catch (\Throwable $Ex) {
175+
return [];
176+
}
177+
}
178+
163179
public function getSourceAppList() : array
164180
{
165181
try {

src/www/index.php

+9
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@
127127
echo json_encode($result);
128128
break;
129129

130+
case '/profiler/all-methods.json':
131+
header('Content-Type: application/json;charset=UTF-8');
132+
133+
/** @var \Badoo\LiveProfilerUI\Pages\AjaxPages $Page */
134+
$Page = $App->getPage('ajax_pages');
135+
136+
echo json_encode($Page->allMethods());
137+
break;
138+
130139
case '/profiler/get-source-app-list.json':
131140
header('Content-Type: application/json;charset=UTF-8');
132141

0 commit comments

Comments
 (0)