mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
69d12f64ba
Summary: Fixes T8352. Associate Diviner books and atoms with a repository. This relationship is not really surfaced anywhere in the UI but provides metadata that contextualises search results. Depends on D13091. Test Plan: Ran `diviner generate --repository ARC` and then went to `/diviner/book/arcanist/`. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7703, T8352 Differential Revision: https://secure.phabricator.com/D13070
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
|
|
|
|
public function getIndexableObject() {
|
|
return new DivinerLiveSymbol();
|
|
}
|
|
|
|
protected function buildAbstractDocumentByPHID($phid) {
|
|
$atom = $this->loadDocumentByPHID($phid);
|
|
$book = $atom->getBook();
|
|
|
|
if (!$atom->getIsDocumentable()) {
|
|
return null;
|
|
}
|
|
|
|
$doc = $this->newDocument($phid)
|
|
->setDocumentTitle($atom->getTitle())
|
|
->setDocumentCreated($book->getDateCreated())
|
|
->setDocumentModified($book->getDateModified());
|
|
|
|
$doc->addField(
|
|
PhabricatorSearchDocumentFieldType::FIELD_BODY,
|
|
$atom->getSummary());
|
|
|
|
$doc->addRelationship(
|
|
PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
|
|
$atom->getBookPHID(),
|
|
DivinerBookPHIDType::TYPECONST,
|
|
PhabricatorTime::getNow());
|
|
|
|
$doc->addRelationship(
|
|
PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
|
|
$atom->getRepositoryPHID(),
|
|
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
|
|
PhabricatorTime::getNow());
|
|
|
|
$doc->addRelationship(
|
|
$atom->getGraphHash()
|
|
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
|
|
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
|
|
$atom->getBookPHID(),
|
|
DivinerBookPHIDType::TYPECONST,
|
|
PhabricatorTime::getNow());
|
|
|
|
return $doc;
|
|
}
|
|
|
|
}
|