1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Reduce the total number of calls to getCallsign()

Summary: Ref T4245. Before doing any hard work here, we can dramatically reduce the number of things that make calls to `getCallsign()` to make navigating things easier. Almost all of them only care about a monogram, URI, or display name.

Test Plan:
- Searched for `r uniquename` in jump nav.
- Ran `bin/repository reparse --change rXXXyyyyy --trace`, observed query against bad commit table.
- Ran `bin/search index rXXXyyyy --trace --force`, observed proper title when indexing commit.
- Browed repository list, saw proper `rXXX` and appropriate link targets.
- Mentioned `rXXX` in Remarkup, got a link to the right place.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14923
This commit is contained in:
epriestley 2016-01-01 17:34:19 -08:00
parent 45ccc930ec
commit ff1bfb64dd
7 changed files with 35 additions and 35 deletions

View file

@ -40,10 +40,11 @@ final class PhabricatorRepositoryRepositoryPHIDType
$monogram = $repository->getMonogram(); $monogram = $repository->getMonogram();
$callsign = $repository->getCallsign(); $callsign = $repository->getCallsign();
$name = $repository->getName(); $name = $repository->getName();
$uri = $repository->getURI();
$handle->setName($monogram); $handle->setName($monogram);
$handle->setFullName("{$monogram} {$name}"); $handle->setFullName("{$monogram} {$name}");
$handle->setURI("/diffusion/{$callsign}/"); $handle->setURI($uri);
} }
} }

View file

@ -155,8 +155,8 @@ final class PhabricatorRepositorySearchEngine
->setUser($viewer) ->setUser($viewer)
->setObject($repository) ->setObject($repository)
->setHeader($repository->getName()) ->setHeader($repository->getName())
->setObjectName('r'.$repository->getCallsign()) ->setObjectName($repository->getMonogram())
->setHref($this->getApplicationURI($repository->getCallsign().'/')); ->setHref($repository->getURI());
$commit = $repository->getMostRecentCommit(); $commit = $repository->getMostRecentCommit();
if ($commit) { if ($commit) {

View file

@ -20,8 +20,10 @@ final class DiffusionCommitFulltextEngine
$commit_message = $commit_data->getCommitMessage(); $commit_message = $commit_data->getCommitMessage();
$author_phid = $commit_data->getCommitDetail('authorPHID'); $author_phid = $commit_data->getCommitDetail('authorPHID');
$title = 'r'.$repository->getCallsign().$commit->getCommitIdentifier(). $monogram = $commit->getMonogram();
' '.$commit_data->getSummary(); $summary = $commit_data->getSummary();
$title = "{$monogram} {$summary}";
$document $document
->setDocumentCreated($date_created) ->setDocumentCreated($date_created)

View file

@ -203,10 +203,7 @@ final class PhabricatorRepositoryCommit
} }
public function getURI() { public function getURI() {
$repository = $this->getRepository(); return '/'.$this->getMonogram();
$callsign = $repository->getCallsign();
$commit_identifier = $this->getCommitIdentifier();
return '/r'.$callsign.$commit_identifier;
} }
/** /**
@ -251,6 +248,14 @@ final class PhabricatorRepositoryCommit
return $this->setAuditStatus($status); return $this->setAuditStatus($status);
} }
public function getMonogram() {
$repository = $this->getRepository();
$callsign = $repository->getCallsign();
$identifier = $this->getCommitIdentifier();
return "r{$callsign}{$identifier}";
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -17,30 +17,26 @@ abstract class PhabricatorRepositoryCommitParserWorker
pht('No "%s" in task data.', 'commitID')); pht('No "%s" in task data.', 'commitID'));
} }
$commit = id(new PhabricatorRepositoryCommit())->load($commit_id); $commit = id(new DiffusionCommitQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withIDs(array($commit_id))
->executeOne();
if (!$commit) { if (!$commit) {
throw new PhabricatorWorkerPermanentFailureException( throw new PhabricatorWorkerPermanentFailureException(
pht('Commit "%s" does not exist.', $commit_id)); pht('Commit "%s" does not exist.', $commit_id));
} }
return $this->commit = $commit; $this->commit = $commit;
return $commit;
} }
final protected function doWork() { final protected function doWork() {
if (!$this->loadCommit()) { $commit = $this->loadCommit();
return; $repository = $commit->getRepository();
}
$repository = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withIDs(array($this->commit->getRepositoryID()))
->executeOne();
if (!$repository) {
return;
}
$this->repository = $repository; $this->repository = $repository;
$this->parseCommit($repository, $this->commit); $this->parseCommit($repository, $this->commit);
} }
@ -52,14 +48,14 @@ abstract class PhabricatorRepositoryCommitParserWorker
PhabricatorRepository $repository, PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit); PhabricatorRepositoryCommit $commit);
protected function isBadCommit($full_commit_name) { protected function isBadCommit(PhabricatorRepositoryCommit $commit) {
$repository = new PhabricatorRepository(); $repository = new PhabricatorRepository();
$bad_commit = queryfx_one( $bad_commit = queryfx_one(
$repository->establishConnection('w'), $repository->establishConnection('w'),
'SELECT * FROM %T WHERE fullCommitName = %s', 'SELECT * FROM %T WHERE fullCommitName = %s',
PhabricatorRepository::TABLE_BADCOMMIT, PhabricatorRepository::TABLE_BADCOMMIT,
$full_commit_name); $commit->getMonogram());
return (bool)$bad_commit; return (bool)$bad_commit;
} }

View file

@ -17,12 +17,8 @@ abstract class PhabricatorRepositoryCommitChangeParserWorker
PhabricatorRepository $repository, PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) { PhabricatorRepositoryCommit $commit) {
$identifier = $commit->getCommitIdentifier(); $this->log("%s\n", pht('Parsing "%s"...', $commit->getMonogram()));
$callsign = $repository->getCallsign(); if ($this->isBadCommit($commit)) {
$full_name = 'r'.$callsign.$identifier;
$this->log("%s\n", pht('Parsing %s...', $full_name));
if ($this->isBadCommit($full_name)) {
$this->log(pht('This commit is marked bad!')); $this->log(pht('This commit is marked bad!'));
return; return;
} }

View file

@ -57,7 +57,7 @@ final class PhabricatorJumpNavHandler extends Phobject {
->execute(); ->execute();
if (count($repositories) == 1) { if (count($repositories) == 1) {
// Just one match, jump to repository. // Just one match, jump to repository.
$uri = '/diffusion/'.head($repositories)->getCallsign().'/'; $uri = head($repositories)->getURI();
} else { } else {
// More than one match, jump to search. // More than one match, jump to search.
$uri = urisprintf('/diffusion/?order=name&name=%s', $name); $uri = urisprintf('/diffusion/?order=name&name=%s', $name);