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();
$callsign = $repository->getCallsign();
$name = $repository->getName();
$uri = $repository->getURI();
$handle->setName($monogram);
$handle->setFullName("{$monogram} {$name}");
$handle->setURI("/diffusion/{$callsign}/");
$handle->setURI($uri);
}
}

View file

@ -155,15 +155,15 @@ final class PhabricatorRepositorySearchEngine
->setUser($viewer)
->setObject($repository)
->setHeader($repository->getName())
->setObjectName('r'.$repository->getCallsign())
->setHref($this->getApplicationURI($repository->getCallsign().'/'));
->setObjectName($repository->getMonogram())
->setHref($repository->getURI());
$commit = $repository->getMostRecentCommit();
if ($commit) {
$commit_link = DiffusionView::linkCommit(
$repository,
$commit->getCommitIdentifier(),
$commit->getSummary());
$repository,
$commit->getCommitIdentifier(),
$commit->getSummary());
$item->setSubhead($commit_link);
$item->setEpoch($commit->getEpoch());
}

View file

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

View file

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

View file

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

View file

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

View file

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