mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 23:32:40 +01:00
Make it easy to find deprecated calls in the Conduit call log
Summary: Ref T9980. This makes it much easier to look for calls to deprecated methods. Test Plan: {F1025851} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9980 Differential Revision: https://secure.phabricator.com/D14781
This commit is contained in:
parent
0692115953
commit
6580bbdf39
3 changed files with 58 additions and 1 deletions
|
@ -139,6 +139,16 @@ abstract class ConduitAPIMethod
|
||||||
return "{$head}.{$ord}.{$tail}";
|
return "{$head}.{$ord}.{$tail}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getMethodStatusMap() {
|
||||||
|
$map = array(
|
||||||
|
self::METHOD_STATUS_STABLE => pht('Stable'),
|
||||||
|
self::METHOD_STATUS_UNSTABLE => pht('Unstable'),
|
||||||
|
self::METHOD_STATUS_DEPRECATED => pht('Deprecated'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $map;
|
||||||
|
}
|
||||||
|
|
||||||
public function getApplicationName() {
|
public function getApplicationName() {
|
||||||
return head(explode('.', $this->getAPIMethodName(), 2));
|
return head(explode('.', $this->getAPIMethodName(), 2));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,18 @@ final class PhabricatorConduitLogQuery
|
||||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
|
|
||||||
private $methods;
|
private $methods;
|
||||||
|
private $methodStatuses;
|
||||||
|
|
||||||
public function withMethods(array $methods) {
|
public function withMethods(array $methods) {
|
||||||
$this->methods = $methods;
|
$this->methods = $methods;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withMethodStatuses(array $statuses) {
|
||||||
|
$this->methodStatuses = $statuses;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function newResultObject() {
|
public function newResultObject() {
|
||||||
return new PhabricatorConduitMethodCallLog();
|
return new PhabricatorConduitMethodCallLog();
|
||||||
}
|
}
|
||||||
|
@ -21,13 +27,38 @@ final class PhabricatorConduitLogQuery
|
||||||
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||||
$where = parent::buildWhereClauseParts($conn);
|
$where = parent::buildWhereClauseParts($conn);
|
||||||
|
|
||||||
if ($this->methods) {
|
if ($this->methods !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn,
|
$conn,
|
||||||
'method IN (%Ls)',
|
'method IN (%Ls)',
|
||||||
$this->methods);
|
$this->methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->methodStatuses !== null) {
|
||||||
|
$statuses = array_fuse($this->methodStatuses);
|
||||||
|
|
||||||
|
$methods = id(new PhabricatorConduitMethodQuery())
|
||||||
|
->setViewer($this->getViewer())
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$method_names = array();
|
||||||
|
foreach ($methods as $method) {
|
||||||
|
$status = $method->getMethodStatus();
|
||||||
|
if (isset($statuses[$status])) {
|
||||||
|
$method_names[] = $method->getAPIMethodName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$method_names) {
|
||||||
|
throw new PhabricatorEmptyQueryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn,
|
||||||
|
'method IN (%Ls)',
|
||||||
|
$method_names);
|
||||||
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class PhabricatorConduitLogSearchEngine
|
||||||
$query->withMethods($map['methods']);
|
$query->withMethods($map['methods']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($map['statuses']) {
|
||||||
|
$query->withMethodStatuses($map['statuses']);
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +35,11 @@ final class PhabricatorConduitLogSearchEngine
|
||||||
->setKey('methods')
|
->setKey('methods')
|
||||||
->setLabel(pht('Methods'))
|
->setLabel(pht('Methods'))
|
||||||
->setDescription(pht('Find calls to specific methods.')),
|
->setDescription(pht('Find calls to specific methods.')),
|
||||||
|
id(new PhabricatorSearchCheckboxesField())
|
||||||
|
->setKey('statuses')
|
||||||
|
->setLabel(pht('Method Status'))
|
||||||
|
->setAliases(array('status'))
|
||||||
|
->setOptions(ConduitAPIMethod::getMethodStatusMap()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +50,7 @@ final class PhabricatorConduitLogSearchEngine
|
||||||
protected function getBuiltinQueryNames() {
|
protected function getBuiltinQueryNames() {
|
||||||
$names = array(
|
$names = array(
|
||||||
'all' => pht('All Logs'),
|
'all' => pht('All Logs'),
|
||||||
|
'deprecated' => pht('Deprecated Calls'),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $names;
|
return $names;
|
||||||
|
@ -51,6 +61,12 @@ final class PhabricatorConduitLogSearchEngine
|
||||||
$query->setQueryKey($query_key);
|
$query->setQueryKey($query_key);
|
||||||
|
|
||||||
switch ($query_key) {
|
switch ($query_key) {
|
||||||
|
case 'deprecated':
|
||||||
|
return $query->setParameter(
|
||||||
|
'statuses',
|
||||||
|
array(
|
||||||
|
ConduitAPIMethod::METHOD_STATUS_DEPRECATED,
|
||||||
|
));
|
||||||
case 'all':
|
case 'all':
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue