Skip to content

Commit

Permalink
added /profiler/all-methods.json
Browse files Browse the repository at this point in the history
  • Loading branch information
shagtv committed Jan 28, 2020
1 parent 8032f77 commit 0523e8c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

There are next changes:

## 1.2.12

There are next changes:

- added a method to return all saved methods

## 1.2.11

There are next changes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
interface MethodInterface
{
public function findByName(string $method_name, bool $strict = false) : array;
public function all() : array;
public function getListByNames(array $names) : array;
public function getListByIds(array $ids) : array;
public function insertMany(array $inserts) : bool;
Expand Down
17 changes: 17 additions & 0 deletions src/Badoo/LiveProfilerUI/DataProviders/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ public function findByName(string $method_name, bool $strict = false) : array
return $methods;
}

public function all() : array
{
$result = $this->AggregatorStorage->getAll(
self::TABLE_NAME,
['all'],
[]
);
$methods = [];
if (!empty($result)) {
foreach ($result as $row) {
$methods[$row['id']] = $row;
}
}

return $methods;
}

public function getListByNames(array $names) : array
{
if (empty($names)) {
Expand Down
16 changes: 16 additions & 0 deletions src/Badoo/LiveProfilerUI/Pages/AjaxPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ public function searchMethods(string $term) : array
}
}

public function allMethods() : array
{
try {
$methods = $this->Method->all();

$result = [];
foreach ($methods as $method) {
$result[$method['name']] = $method['date'];
}

return $result;
} catch (\Throwable $Ex) {
return [];
}
}

public function getSourceAppList() : array
{
try {
Expand Down
9 changes: 9 additions & 0 deletions src/www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@
echo json_encode($result);
break;

case '/profiler/all-methods.json':
header('Content-Type: application/json;charset=UTF-8');

/** @var \Badoo\LiveProfilerUI\Pages\AjaxPages $Page */
$Page = $App->getPage('ajax_pages');

echo json_encode($Page->allMethods());
break;

case '/profiler/get-source-app-list.json':
header('Content-Type: application/json;charset=UTF-8');

Expand Down

0 comments on commit 0523e8c

Please sign in to comment.