mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 23:01:04 +01:00
Add repositories to fulltext search index.
Summary: This implements a simplistic `PhabricatorRepositoryFulltextEngine` Currently only the repository name, description, timestamps and status are indexed. Note: I had to change the `search index` workflow to disambiguate PhabricatorRepository from PhabricatorRepositoryCommit Test Plan: * ran `./bin/search index --type PhabricatorRepository --force` * searched for some repositories. Saw reasonable results matching on either title or description. * Edited a repository in the web ui * Added unique key words to the repo description. * I was then able to find that repo by searching for the new keywords. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin Tags: #search, #diffusion Differential Revision: https://secure.phabricator.com/D17300
This commit is contained in:
parent
9e2ab4f80e
commit
9e2f263bb4
4 changed files with 45 additions and 1 deletions
|
@ -3660,6 +3660,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php',
|
'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php',
|
||||||
'PhabricatorRepositoryEditor' => 'applications/repository/editor/PhabricatorRepositoryEditor.php',
|
'PhabricatorRepositoryEditor' => 'applications/repository/editor/PhabricatorRepositoryEditor.php',
|
||||||
'PhabricatorRepositoryEngine' => 'applications/repository/engine/PhabricatorRepositoryEngine.php',
|
'PhabricatorRepositoryEngine' => 'applications/repository/engine/PhabricatorRepositoryEngine.php',
|
||||||
|
'PhabricatorRepositoryFulltextEngine' => 'applications/repository/search/PhabricatorRepositoryFulltextEngine.php',
|
||||||
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php',
|
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php',
|
||||||
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php',
|
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php',
|
||||||
'PhabricatorRepositoryGitLFSRef' => 'applications/repository/storage/PhabricatorRepositoryGitLFSRef.php',
|
'PhabricatorRepositoryGitLFSRef' => 'applications/repository/storage/PhabricatorRepositoryGitLFSRef.php',
|
||||||
|
@ -8910,6 +8911,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectInterface',
|
'PhabricatorProjectInterface',
|
||||||
'PhabricatorSpacesInterface',
|
'PhabricatorSpacesInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
|
'PhabricatorFulltextInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorRepositoryAuditRequest' => array(
|
'PhabricatorRepositoryAuditRequest' => array(
|
||||||
'PhabricatorRepositoryDAO',
|
'PhabricatorRepositoryDAO',
|
||||||
|
@ -8951,6 +8953,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine',
|
'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine',
|
||||||
'PhabricatorRepositoryEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorRepositoryEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorRepositoryEngine' => 'Phobject',
|
'PhabricatorRepositoryEngine' => 'Phobject',
|
||||||
|
'PhabricatorRepositoryFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||||
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
|
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
|
||||||
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
|
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
|
||||||
'PhabricatorRepositoryGitLFSRef' => array(
|
'PhabricatorRepositoryGitLFSRef' => array(
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorRepositoryFulltextEngine
|
||||||
|
extends PhabricatorFulltextEngine {
|
||||||
|
|
||||||
|
protected function buildAbstractDocument(
|
||||||
|
PhabricatorSearchAbstractDocument $document,
|
||||||
|
$object) {
|
||||||
|
$repo = $object;
|
||||||
|
$document->setDocumentTitle($repo->getName());
|
||||||
|
$document->addField(
|
||||||
|
PhabricatorSearchDocumentFieldType::FIELD_BODY,
|
||||||
|
$repo->getRepositorySlug()."\n".$repo->getDetail('description'));
|
||||||
|
|
||||||
|
$document->setDocumentCreated($repo->getDateCreated());
|
||||||
|
$document->setDocumentModified($repo->getDateModified());
|
||||||
|
|
||||||
|
$document->addRelationship(
|
||||||
|
$repo->isTracked()
|
||||||
|
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
|
||||||
|
: PhabricatorSearchRelationship::RELATIONSHIP_CLOSED,
|
||||||
|
$repo->getPHID(),
|
||||||
|
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
|
||||||
|
PhabricatorTime::getNow());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
PhabricatorDestructibleInterface,
|
PhabricatorDestructibleInterface,
|
||||||
PhabricatorProjectInterface,
|
PhabricatorProjectInterface,
|
||||||
PhabricatorSpacesInterface,
|
PhabricatorSpacesInterface,
|
||||||
PhabricatorConduitResultInterface {
|
PhabricatorConduitResultInterface,
|
||||||
|
PhabricatorFulltextInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortest hash we'll recognize in raw "a829f32" form.
|
* Shortest hash we'll recognize in raw "a829f32" form.
|
||||||
|
@ -2572,4 +2573,11 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -( PhabricatorFulltextInterface )--------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function newFulltextEngine() {
|
||||||
|
return new PhabricatorRepositoryFulltextEngine();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,9 +158,15 @@ final class PhabricatorSearchManagementIndexWorkflow
|
||||||
$object_class = get_class($object);
|
$object_class = get_class($object);
|
||||||
$normalized_class = phutil_utf8_strtolower($object_class);
|
$normalized_class = phutil_utf8_strtolower($object_class);
|
||||||
|
|
||||||
|
if ($normalized_class === $normalized_type) {
|
||||||
|
$matches = array($object_class => $object);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strlen($type) ||
|
if (!strlen($type) ||
|
||||||
strpos($normalized_class, $normalized_type) !== false) {
|
strpos($normalized_class, $normalized_type) !== false) {
|
||||||
$matches[$object_class] = $object;
|
$matches[$object_class] = $object;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue