1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +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:
epriestley 2015-12-14 13:05:41 -08:00
parent 0692115953
commit 6580bbdf39
3 changed files with 58 additions and 1 deletions

View file

@ -139,6 +139,16 @@ abstract class ConduitAPIMethod
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() {
return head(explode('.', $this->getAPIMethodName(), 2));
}

View file

@ -4,12 +4,18 @@ final class PhabricatorConduitLogQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $methods;
private $methodStatuses;
public function withMethods(array $methods) {
$this->methods = $methods;
return $this;
}
public function withMethodStatuses(array $statuses) {
$this->methodStatuses = $statuses;
return $this;
}
public function newResultObject() {
return new PhabricatorConduitMethodCallLog();
}
@ -21,13 +27,38 @@ final class PhabricatorConduitLogQuery
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
if ($this->methods) {
if ($this->methods !== null) {
$where[] = qsprintf(
$conn,
'method IN (%Ls)',
$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;
}

View file

@ -22,6 +22,10 @@ final class PhabricatorConduitLogSearchEngine
$query->withMethods($map['methods']);
}
if ($map['statuses']) {
$query->withMethodStatuses($map['statuses']);
}
return $query;
}
@ -31,6 +35,11 @@ final class PhabricatorConduitLogSearchEngine
->setKey('methods')
->setLabel(pht('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() {
$names = array(
'all' => pht('All Logs'),
'deprecated' => pht('Deprecated Calls'),
);
return $names;
@ -51,6 +61,12 @@ final class PhabricatorConduitLogSearchEngine
$query->setQueryKey($query_key);
switch ($query_key) {
case 'deprecated':
return $query->setParameter(
'statuses',
array(
ConduitAPIMethod::METHOD_STATUS_DEPRECATED,
));
case 'all':
return $query;
}