mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 15:00:58 +01:00
f82e4b0c70
Summary: Ref T603. Ref T2625. Long chain of "doing the right thing" here: I want to clean this up, so I can clean up the Conduit logs, so I can add a setup issue for deprecated method calls, so I can remove deprecated methods, so I can get rid of `DifferentialRevisionListData`, so I can make Differntial policy-aware. Adds modern infrastructure and UI to all of the Conduit interfaces (except only partially for the logs, that will be the next diff). Test Plan: {F48201} {F48202} {F48203} {F48204} {F48206} This will get further updates in the next diff: {F48205} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T603, T2625 Differential Revision: https://secure.phabricator.com/D6331
103 lines
2.6 KiB
PHP
103 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group conduit
|
|
*/
|
|
final class PhabricatorConduitLogController
|
|
extends PhabricatorConduitController {
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
|
|
$conn_table = new PhabricatorConduitConnectionLog();
|
|
$call_table = new PhabricatorConduitMethodCallLog();
|
|
|
|
$conn_r = $call_table->establishConnection('r');
|
|
|
|
$pager = new AphrontPagerView();
|
|
$pager->setOffset($request->getInt('page'));
|
|
$calls = $call_table->loadAllWhere(
|
|
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
|
|
$pager->getOffset(),
|
|
$pager->getPageSize() + 1);
|
|
$calls = $pager->sliceResults($calls);
|
|
$pager->setURI(new PhutilURI('/conduit/log/'), 'page');
|
|
$pager->setEnableKeyboardShortcuts(true);
|
|
|
|
$min = $pager->getOffset() + 1;
|
|
$max = ($min + count($calls) - 1);
|
|
|
|
$conn_ids = array_filter(mpull($calls, 'getConnectionID'));
|
|
$conns = array();
|
|
if ($conn_ids) {
|
|
$conns = $conn_table->loadAllWhere(
|
|
'id IN (%Ld)',
|
|
$conn_ids);
|
|
}
|
|
|
|
$table = $this->renderCallTable($calls, $conns);
|
|
$panel = new AphrontPanelView();
|
|
$panel->setHeader('Conduit Method Calls ('.$min.'-'.$max.')');
|
|
$panel->appendChild($table);
|
|
$panel->appendChild($pager);
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumbs->addCrumb(
|
|
id(new PhabricatorCrumbView())
|
|
->setName(pht('Call Logs')));
|
|
|
|
return $this->buildApplicationPage(
|
|
array(
|
|
$crumbs,
|
|
$panel,
|
|
),
|
|
array(
|
|
'title' => 'Conduit Logs',
|
|
));
|
|
}
|
|
|
|
private function renderCallTable(array $calls, array $conns) {
|
|
assert_instances_of($calls, 'PhabricatorConduitMethodCallLog');
|
|
assert_instances_of($conns, 'PhabricatorConduitConnectionLog');
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$rows = array();
|
|
foreach ($calls as $call) {
|
|
$conn = idx($conns, $call->getConnectionID());
|
|
if (!$conn) {
|
|
// If there's no connection, use an empty object.
|
|
$conn = new PhabricatorConduitConnectionLog();
|
|
}
|
|
$rows[] = array(
|
|
$call->getConnectionID(),
|
|
$conn->getUserName(),
|
|
$call->getMethod(),
|
|
$call->getError(),
|
|
number_format($call->getDuration()).' us',
|
|
phabricator_datetime($call->getDateCreated(), $user),
|
|
);
|
|
}
|
|
$table = new AphrontTableView($rows);
|
|
$table->setHeaders(
|
|
array(
|
|
'Connection',
|
|
'User',
|
|
'Method',
|
|
'Error',
|
|
'Duration',
|
|
'Date',
|
|
));
|
|
$table->setColumnClasses(
|
|
array(
|
|
'',
|
|
'',
|
|
'wide',
|
|
'',
|
|
'n',
|
|
'right',
|
|
));
|
|
return $table;
|
|
}
|
|
|
|
}
|