1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Add more options to repository.query

Summary: Expose more options on `repository.query`. My broad goal here is to move forward on suppressing Arcanist Projects.

Test Plan: Used Conduit console to execute queries.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D8068
This commit is contained in:
epriestley 2014-01-25 14:02:28 -08:00
parent 31e11a97d2
commit ce45c57057
2 changed files with 39 additions and 9 deletions

View file

@ -1,8 +1,5 @@
<?php
/**
* @group conduit
*/
final class ConduitAPI_repository_query_Method
extends ConduitAPI_repository_Method {
@ -11,15 +8,19 @@ final class ConduitAPI_repository_query_Method
}
public function getMethodStatusDescription() {
return "Repository methods are new and subject to change.";
return pht("Repository methods are new and subject to change.");
}
public function getMethodDescription() {
return "Query repositories.";
return pht("Query repositories.");
}
public function defineParamTypes() {
return array(
'ids' => 'optional list<int>',
'phids' => 'optional list<phid>',
'callsigns' => 'optional list<string>',
'vcsTypes' => 'optional list<string>',
);
}
@ -33,9 +34,30 @@ final class ConduitAPI_repository_query_Method
}
protected function execute(ConduitAPIRequest $request) {
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser())
->execute();
$query = id(new PhabricatorRepositoryQuery())
->setViewer($request->getUser());
$ids = $request->getValue('ids', array());
if ($ids) {
$query->withIDs($ids);
}
$phids = $request->getValue('phids', array());
if ($phids) {
$query->withPHIDs($phids);
}
$callsigns = $request->getValue('callsigns', array());
if ($callsigns) {
$query->withCallsigns($callsigns);
}
$vcs_types = $request->getValue('vcsTypes', array());
if ($vcs_types) {
$query->withTypes($vcs_types);
}
$repositories = $query->execute();
$results = array();
foreach ($repositories as $repository) {

View file

@ -77,17 +77,25 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
public function toDictionary() {
return array(
'id' => $this->getID(),
'name' => $this->getName(),
'phid' => $this->getPHID(),
'callsign' => $this->getCallsign(),
'monogram' => $this->getMonogram(),
'vcs' => $this->getVersionControlSystem(),
'uri' => PhabricatorEnv::getProductionURI($this->getURI()),
'remoteURI' => (string)$this->getRemoteURI(),
'tracking' => $this->getDetail('tracking-enabled'),
'description' => $this->getDetail('description'),
'isActive' => $this->isTracked(),
'isHosted' => $this->isHosted(),
'isImporting' => $this->isImporting(),
);
}
public function getMonogram() {
return 'r'.$this->getCallsign();
}
public function getDetail($key, $default = null) {
return idx($this->details, $key, $default);
}