Differential D12894 Diff 31029 src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/conduit/DifferentialQueryConduitAPIMethod.php
Show All 38 Lines | return array( | ||||
'order' => 'optional '.$order_const, | 'order' => 'optional '.$order_const, | ||||
'limit' => 'optional uint', | 'limit' => 'optional uint', | ||||
'offset' => 'optional uint', | 'offset' => 'optional uint', | ||||
'ids' => 'optional list<uint>', | 'ids' => 'optional list<uint>', | ||||
'phids' => 'optional list<phid>', | 'phids' => 'optional list<phid>', | ||||
'subscribers' => 'optional list<phid>', | 'subscribers' => 'optional list<phid>', | ||||
'responsibleUsers' => 'optional list<phid>', | 'responsibleUsers' => 'optional list<phid>', | ||||
'branches' => 'optional list<string>', | 'branches' => 'optional list<string>', | ||||
'arcanistProjects' => 'optional list<string>', | |||||
); | ); | ||||
} | } | ||||
protected function defineReturnType() { | protected function defineReturnType() { | ||||
return 'list<dict>'; | return 'list<dict>'; | ||||
} | } | ||||
protected function defineErrorTypes() { | protected function defineErrorTypes() { | ||||
Show All 12 Lines | protected function execute(ConduitAPIRequest $request) { | ||||
$commit_hashes = $request->getValue('commitHashes'); | $commit_hashes = $request->getValue('commitHashes'); | ||||
$limit = $request->getValue('limit'); | $limit = $request->getValue('limit'); | ||||
$offset = $request->getValue('offset'); | $offset = $request->getValue('offset'); | ||||
$ids = $request->getValue('ids'); | $ids = $request->getValue('ids'); | ||||
$phids = $request->getValue('phids'); | $phids = $request->getValue('phids'); | ||||
$subscribers = $request->getValue('subscribers'); | $subscribers = $request->getValue('subscribers'); | ||||
$responsible_users = $request->getValue('responsibleUsers'); | $responsible_users = $request->getValue('responsibleUsers'); | ||||
$branches = $request->getValue('branches'); | $branches = $request->getValue('branches'); | ||||
$arc_projects = $request->getValue('arcanistProjects'); | |||||
$query = id(new DifferentialRevisionQuery()) | $query = id(new DifferentialRevisionQuery()) | ||||
->setViewer($request->getUser()); | ->setViewer($request->getUser()); | ||||
if ($authors) { | if ($authors) { | ||||
$query->withAuthors($authors); | $query->withAuthors($authors); | ||||
} | } | ||||
if ($ccs) { | if ($ccs) { | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | if ($responsible_users) { | ||||
$query->withResponsibleUsers($responsible_users); | $query->withResponsibleUsers($responsible_users); | ||||
} | } | ||||
if ($subscribers) { | if ($subscribers) { | ||||
$query->withCCs($subscribers); | $query->withCCs($subscribers); | ||||
} | } | ||||
if ($branches) { | if ($branches) { | ||||
$query->withBranches($branches); | $query->withBranches($branches); | ||||
} | } | ||||
if ($arc_projects) { | |||||
// This is sort of special-cased, but don't make arc do an extra round | |||||
// trip. | |||||
$projects = id(new PhabricatorRepositoryArcanistProject()) | |||||
->loadAllWhere( | |||||
'name in (%Ls)', | |||||
$arc_projects); | |||||
if (!$projects) { | |||||
return array(); | |||||
} | |||||
$query->withArcanistProjectPHIDs(mpull($projects, 'getPHID')); | |||||
} | |||||
$query->needRelationships(true); | $query->needRelationships(true); | ||||
$query->needCommitPHIDs(true); | $query->needCommitPHIDs(true); | ||||
$query->needDiffIDs(true); | $query->needDiffIDs(true); | ||||
$query->needActiveDiffs(true); | $query->needActiveDiffs(true); | ||||
$query->needHashes(true); | $query->needHashes(true); | ||||
$revisions = $query->execute(); | $revisions = $query->execute(); | ||||
Show All 30 Lines | foreach ($revisions as $revision) { | ||||
'lineCount' => $revision->getLineCount(), | 'lineCount' => $revision->getLineCount(), | ||||
'activeDiffPHID' => $diff->getPHID(), | 'activeDiffPHID' => $diff->getPHID(), | ||||
'diffs' => $revision->getDiffIDs(), | 'diffs' => $revision->getDiffIDs(), | ||||
'commits' => $revision->getCommitPHIDs(), | 'commits' => $revision->getCommitPHIDs(), | ||||
'reviewers' => array_values($revision->getReviewers()), | 'reviewers' => array_values($revision->getReviewers()), | ||||
'ccs' => array_values($revision->getCCPHIDs()), | 'ccs' => array_values($revision->getCCPHIDs()), | ||||
'hashes' => $revision->getHashes(), | 'hashes' => $revision->getHashes(), | ||||
'auxiliary' => idx($field_data, $phid, array()), | 'auxiliary' => idx($field_data, $phid, array()), | ||||
'arcanistProjectPHID' => $diff->getArcanistProjectPHID(), | |||||
'repositoryPHID' => $diff->getRepositoryPHID(), | 'repositoryPHID' => $diff->getRepositoryPHID(), | ||||
); | ); | ||||
// TODO: This is a hacky way to put permissions on this field until we | // TODO: This is a hacky way to put permissions on this field until we | ||||
// have first-class support, see T838. | // have first-class support, see T838. | ||||
if ($revision->getAuthorPHID() == $request->getUser()->getPHID()) { | if ($revision->getAuthorPHID() == $request->getUser()->getPHID()) { | ||||
$result['sourcePath'] = $diff->getSourcePath(); | $result['sourcePath'] = $diff->getSourcePath(); | ||||
} | } | ||||
$results[] = $result; | $results[] = $result; | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
} | } |