Differential D12552 Diff 30169 src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
Show All 11 Lines | final class DiffusionBranchQueryConduitAPIMethod | ||||
} | } | ||||
protected function defineReturnType() { | protected function defineReturnType() { | ||||
return 'list<dict>'; | return 'list<dict>'; | ||||
} | } | ||||
protected function defineCustomParamTypes() { | protected function defineCustomParamTypes() { | ||||
return array( | return array( | ||||
'closed' => 'optional bool', | |||||
'limit' => 'optional int', | 'limit' => 'optional int', | ||||
'offset' => 'optional int', | 'offset' => 'optional int', | ||||
'contains' => 'optional string', | 'contains' => 'optional string', | ||||
); | ); | ||||
} | } | ||||
protected function getGitResult(ConduitAPIRequest $request) { | protected function getGitResult(ConduitAPIRequest $request) { | ||||
$drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | private function processBranchRefs(ConduitAPIRequest $request, array $refs) { | ||||
$limit = $request->getValue('limit'); | $limit = $request->getValue('limit'); | ||||
foreach ($refs as $key => $ref) { | foreach ($refs as $key => $ref) { | ||||
if (!$repository->shouldTrackBranch($ref->getShortName())) { | if (!$repository->shouldTrackBranch($ref->getShortName())) { | ||||
unset($refs[$key]); | unset($refs[$key]); | ||||
} | } | ||||
} | } | ||||
$with_closed = $request->getValue('closed'); | |||||
if ($with_closed !== null) { | |||||
foreach ($refs as $key => $ref) { | |||||
$fields = $ref->getRawFields(); | |||||
if (idx($fields, 'closed') != $with_closed) { | |||||
unset($refs[$key]); | |||||
} | |||||
} | |||||
} | |||||
// NOTE: We can't apply the offset or limit until here, because we may have | // NOTE: We can't apply the offset or limit until here, because we may have | ||||
// filtered untrackable branches out of the result set. | // filtered untrackable branches out of the result set. | ||||
if ($offset) { | if ($offset) { | ||||
$refs = array_slice($refs, $offset); | $refs = array_slice($refs, $offset); | ||||
} | } | ||||
if ($limit) { | if ($limit) { | ||||
$refs = array_slice($refs, 0, $limit); | $refs = array_slice($refs, 0, $limit); | ||||
} | } | ||||
return mpull($refs, 'toDictionary'); | return mpull($refs, 'toDictionary'); | ||||
} | } | ||||
} | } |