Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/releeph/conduit/ReleephGetBranchesConduitAPIMethod.php b/src/applications/releeph/conduit/ReleephGetBranchesConduitAPIMethod.php
index 6e225ec8e3..469713ce39 100644
--- a/src/applications/releeph/conduit/ReleephGetBranchesConduitAPIMethod.php
+++ b/src/applications/releeph/conduit/ReleephGetBranchesConduitAPIMethod.php
@@ -1,61 +1,59 @@
<?php
final class ReleephGetBranchesConduitAPIMethod extends ReleephConduitAPIMethod {
public function getAPIMethodName() {
return 'releeph.getbranches';
}
public function getMethodDescription() {
return pht('Return information about all active Releeph branches.');
}
protected function defineParamTypes() {
return array(
);
}
protected function defineReturnType() {
return 'nonempty list<dict<string, wild>>';
}
protected function execute(ConduitAPIRequest $request) {
$results = array();
$projects = id(new ReleephProductQuery())
->setViewer($request->getUser())
->withActive(1)
->execute();
foreach ($projects as $project) {
$repository = $project->getRepository();
- $branches = $project->loadRelatives(
- id(new ReleephBranch()),
- 'releephProjectID',
- 'getID',
- 'isActive = 1');
+ $branches = id(new ReleephBranch())->loadAllWhere(
+ 'releephProjectID = %d AND isActive = 1',
+ $project->getID());
foreach ($branches as $branch) {
$full_branch_name = $branch->getName();
$cut_point_commit = $branch->loadOneRelative(
id(new PhabricatorRepositoryCommit()),
'phid',
'getCutPointCommitPHID');
$results[] = array(
'project' => $project->getName(),
'repository' => $repository->getCallsign(),
'branch' => $branch->getBasename(),
'fullBranchName' => $full_branch_name,
'symbolicName' => $branch->getSymbolicName(),
'cutPoint' => $cut_point_commit->getCommitIdentifier(),
);
}
}
return $results;
}
}
diff --git a/src/applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php b/src/applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php
index 5975f208e6..20c8d5e226 100644
--- a/src/applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php
+++ b/src/applications/releeph/field/specification/ReleephDiffSizeFieldSpecification.php
@@ -1,117 +1,118 @@
<?php
final class ReleephDiffSizeFieldSpecification
extends ReleephFieldSpecification {
const LINES_WEIGHT = 1;
const PATHS_WEIGHT = 30;
const MAX_POINTS = 1000;
public function getFieldKey() {
return 'commit:size';
}
public function getName() {
return pht('Size');
}
public function renderPropertyViewValue(array $handles) {
$requested_object = $this->getObject()->getRequestedObject();
if (!($requested_object instanceof DifferentialRevision)) {
return null;
}
$diff_rev = $requested_object;
- $diffs = $diff_rev->loadRelatives(
- new DifferentialDiff(),
- 'revisionID',
- 'getID',
- 'creationMethod <> "commit"');
+ $diffs = id(new DifferentialDiff())->loadAllWhere(
+ 'revisionID = %d AND creationMethod != %s',
+ $diff_rev->getID(),
+ 'commit');
$all_changesets = array();
$most_recent_changesets = null;
foreach ($diffs as $diff) {
- $changesets = $diff->loadRelatives(new DifferentialChangeset(), 'diffID');
+ $changesets = id(new DifferentialChangeset())->loadAllWhere(
+ 'diffID = %d',
+ $diff->getID());
$all_changesets += $changesets;
$most_recent_changesets = $changesets;
}
// The score is based on all changesets for all versions of this diff
$all_changes = $this->countLinesAndPaths($all_changesets);
$points =
self::LINES_WEIGHT * $all_changes['code']['lines'] +
self::PATHS_WEIGHT * count($all_changes['code']['paths']);
// The blurb is just based on the most recent version of the diff
$mr_changes = $this->countLinesAndPaths($most_recent_changesets);
$test_tag = '';
if ($mr_changes['tests']['paths']) {
Javelin::initBehavior('phabricator-tooltips');
require_celerity_resource('aphront-tooltip-css');
$test_blurb = pht(
"%d line(s) and %d path(s) contain changes to test code:\n",
$mr_changes['tests']['lines'],
count($mr_changes['tests']['paths']));
foreach ($mr_changes['tests']['paths'] as $mr_test_path) {
$test_blurb .= sprintf("%s\n", $mr_test_path);
}
$test_tag = javelin_tag(
'span',
array(
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $test_blurb,
'align' => 'E',
'size' => 'auto',
),
'style' => '',
),
' + tests');
}
$blurb = hsprintf('%s%s.',
pht(
'%d line(s) and %d path(s) over %d diff(s)',
$mr_changes['code']['lines'],
$mr_changes['code']['paths'],
count($diffs)),
$test_tag);
return id(new AphrontProgressBarView())
->setValue($points)
->setMax(self::MAX_POINTS)
->setCaption($blurb)
->render();
}
private function countLinesAndPaths(array $changesets) {
assert_instances_of($changesets, 'DifferentialChangeset');
$lines = 0;
$paths_touched = array();
$test_lines = 0;
$test_paths_touched = array();
foreach ($changesets as $ch) {
if ($this->getReleephProject()->isTestFile($ch->getFilename())) {
$test_lines += $ch->getAddLines() + $ch->getDelLines();
$test_paths_touched[] = $ch->getFilename();
} else {
$lines += $ch->getAddLines() + $ch->getDelLines();
$paths_touched[] = $ch->getFilename();
}
}
return array(
'code' => array(
'lines' => $lines,
'paths' => array_unique($paths_touched),
),
'tests' => array(
'lines' => $test_lines,
'paths' => array_unique($test_paths_touched),
),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 3, 3:08 PM (9 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
165919
Default Alt Text
(6 KB)

Event Timeline