protected function buildAbstractDocumentByPHID($phid) { $task = $this->loadDocumentByPHID($phid); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($task->getPHID()); $doc->setDocumentType(ManiphestTaskPHIDType::TYPECONST); $doc->setDocumentTitle($task->getTitle()); $doc->setDocumentCreated($task->getDateCreated()); $doc->setDocumentModified($task->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $task->getDescription()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $task->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $task->getDateCreated()); $doc->addRelationship($task->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $task->getPHID(), ManiphestTaskPHIDType::TYPECONST, time()); $this->indexTransactions($doc, new ManiphestTransactionQuery(), array($phid)); foreach ($task->getProjectPHIDs() as $phid) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $phid, PhabricatorProjectProjectPHIDType::TYPECONST, $task->getDateModified()); // Bogus. } $owner = $task->getOwnerPHID(); if ($owner) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $owner, PhabricatorPeopleUserPHIDType::TYPECONST, time()); } else { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $task->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $task->getDateCreated()); } // We need to load handles here since non-users may subscribe (mailing // lists, e.g.) $ccs = $task->getCCPHIDs(); $handles = id(new PhabricatorHandleQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($ccs)->execute(); foreach ($ccs as $cc) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $handles[$cc]->getPHID(), $handles[$cc]->getType(), time()); } return $doc; }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $project = $object; $project->updateDatasourceTokens(); $document->setDocumentTitle($project->getName()); $document->addRelationship($project->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $project->getPHID(), PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorTime::getNow()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $book = $object; $document->setDocumentTitle($book->getTitle()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $book->getPreface()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY, $book->getRepositoryPHID(), PhabricatorRepositoryRepositoryPHIDType::TYPECONST, $book->getDateCreated()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $mock = $object; $document->setDocumentTitle($mock->getName()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $mock->getDescription()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $mock->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $mock->getDateCreated()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $credential = $object; $document->setDocumentTitle($credential->getName()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $credential->getDescription()); $document->addRelationship($credential->getIsDestroyed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $credential->getPHID(), PassphraseCredentialPHIDType::TYPECONST, PhabricatorTime::getNow()); }
protected function buildAbstractDocumentByPHID($phid) { $commit = $this->loadDocumentByPHID($phid); $commit_data = id(new PhabricatorRepositoryCommitData())->loadOneWhere('commitID = %d', $commit->getID()); $date_created = $commit->getEpoch(); $commit_message = $commit_data->getCommitMessage(); $author_phid = $commit_data->getCommitDetail('authorPHID'); $repository = id(new PhabricatorRepositoryQuery())->setViewer($this->getViewer())->withIDs(array($commit->getRepositoryID()))->executeOne(); if (!$repository) { throw new Exception(pht('No such repository!')); } $title = 'r' . $repository->getCallsign() . $commit->getCommitIdentifier() . ' ' . $commit_data->getSummary(); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($commit->getPHID()); $doc->setDocumentType(PhabricatorRepositoryCommitPHIDType::TYPECONST); $doc->setDocumentCreated($date_created); $doc->setDocumentModified($date_created); $doc->setDocumentTitle($title); $doc->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $commit_message); if ($author_phid) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $author_phid, PhabricatorPeopleUserPHIDType::TYPECONST, $date_created); } $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY, $repository->getPHID(), PhabricatorRepositoryRepositoryPHIDType::TYPECONST, $date_created); $this->indexTransactions($doc, new PhabricatorAuditTransactionQuery(), array($commit->getPHID())); return $doc; }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $blog = $object; $document->setDocumentTitle($blog->getName()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $blog->getDescription()); $document->addRelationship($blog->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $blog->getPHID(), PhabricatorPhameBlogPHIDType::TYPECONST, PhabricatorTime::getNow()); }
public static function reindexAbstractDocument(PhabricatorSearchAbstractDocument $doc) { $phid = $doc->getPHID(); if (!$phid) { throw new Exception("Document has no PHID!"); } $store = new PhabricatorSearchDocument(); $store->setPHID($doc->getPHID()); $store->setDocumentType($doc->getDocumentType()); $store->setDocumentTitle($doc->getDocumentTitle()); $store->setDocumentCreated($doc->getDocumentCreated()); $store->setDocumentModified($doc->getDocumentModified()); $store->replace(); $conn_w = $store->establishConnection('w'); $field_dao = new PhabricatorSearchDocumentField(); queryfx($conn_w, 'DELETE FROM %T WHERE phid = %s', $field_dao->getTableName(), $phid); foreach ($doc->getFieldData() as $field) { list($ftype, $corpus, $aux_phid) = $field; queryfx($conn_w, 'INSERT INTO %T (phid, phidType, field, auxPHID, corpus) ' . ' VALUES (%s, %s, %s, %ns, %s)', $field_dao->getTableName(), $phid, $doc->getDocumentType(), $ftype, $aux_phid, $corpus); } $sql = array(); foreach ($doc->getRelationshipData() as $relationship) { list($rtype, $to_phid, $to_type, $time) = $relationship; $sql[] = qsprintf($conn_w, '(%s, %s, %s, %s, %d)', $phid, $to_phid, $rtype, $to_type, $time); } $rship_dao = new PhabricatorSearchDocumentRelationship(); queryfx($conn_w, 'DELETE FROM %T WHERE phid = %s', $rship_dao->getTableName(), $phid); if ($sql) { queryfx($conn_w, 'INSERT INTO %T' . ' (phid, relatedPHID, relation, relatedType, relatedTime) ' . ' VALUES %Q', $rship_dao->getTableName(), implode(', ', $sql)); } }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $initiative = $object; $document->setDocumentTitle($initiative->getName()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $initiative->getOwnerPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $initiative->getDateCreated()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $initiative->getOwnerPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $initiative->getDateCreated()); $document->addRelationship($initiative->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $initiative->getPHID(), FundInitiativePHIDType::TYPECONST, PhabricatorTime::getNow()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $post = $object; $document->setDocumentTitle($post->getTitle()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $post->getBody()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $post->getBloggerPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $post->getDateCreated()); $document->addRelationship($post->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $post->getPHID(), PhabricatorPhamePostPHIDType::TYPECONST, PhabricatorTime::getNow()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $package = $object; $document->setDocumentTitle($package->getName()); // TODO: These are bogus, but not currently stored on packages. $document->setDocumentCreated(PhabricatorTime::getNow()); $document->setDocumentModified(PhabricatorTime::getNow()); $document->addRelationship($package->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $package->getPHID(), PhabricatorOwnersPackagePHIDType::TYPECONST, PhabricatorTime::getNow()); }
protected function buildAbstractDocumentByPHID($phid) { $rev = $this->loadDocumentByPHID($phid); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($rev->getPHID()); $doc->setDocumentType(DifferentialRevisionPHIDType::TYPECONST); $doc->setDocumentTitle($rev->getTitle()); $doc->setDocumentCreated($rev->getDateCreated()); $doc->setDocumentModified($rev->getDateModified()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $rev->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $rev->getDateCreated()); $doc->addRelationship($rev->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $rev->getPHID(), DifferentialRevisionPHIDType::TYPECONST, time()); $this->indexTransactions($doc, new DifferentialTransactionQuery(), array($rev->getPHID())); // If a revision needs review, the owners are the reviewers. Otherwise, the // owner is the author (e.g., accepted, rejected, closed). if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) { $reviewers = $rev->getReviewerStatus(); $reviewers = mpull($reviewers, 'getReviewerPHID', 'getReviewerPHID'); if ($reviewers) { foreach ($reviewers as $phid) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, PhabricatorPeopleUserPHIDType::TYPECONST, $rev->getDateModified()); // Bogus timestamp. } } else { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $rev->getPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $rev->getDateModified()); // Bogus timestamp. } } else { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $rev->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $rev->getDateCreated()); } return $doc; }
public function indexFulltextObject($object, PhabricatorSearchAbstractDocument $document) { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($object->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if (!$project_phids) { return; } foreach ($project_phids as $project_phid) { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $project_phid, PhabricatorProjectProjectPHIDType::TYPECONST, $document->getDocumentModified()); // Bogus timestamp. } }
protected function indexTransactions(PhabricatorSearchAbstractDocument $doc, PhabricatorApplicationTransactionQuery $query, array $phids) { $xactions = id(clone $query)->setViewer($this->getViewer())->withObjectPHIDs($phids)->execute(); foreach ($xactions as $xaction) { if (!$xaction->hasComment()) { continue; } $comment = $xaction->getComment(); $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $comment->getContent()); } }
public function indexFulltextObject($object, PhabricatorSearchAbstractDocument $document) { $subscriber_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID($object->getPHID()); if (!$subscriber_phids) { return; } $handles = id(new PhabricatorHandleQuery())->setViewer($this->getViewer())->withPHIDs($subscriber_phids)->execute(); foreach ($handles as $phid => $handle) { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $phid, $handle->getType(), $document->getDocumentModified()); // Bogus timestamp. } }
public function indexFulltextObject($object, PhabricatorSearchAbstractDocument $document) { $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object); if (!$query) { return; } $xactions = $query->setViewer($this->getViewer())->withObjectPHIDs(array($object->getPHID()))->needComments(true)->execute(); foreach ($xactions as $xaction) { if (!$xaction->hasComment()) { continue; } $comment = $xaction->getComment(); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_COMMENT, $comment->getContent()); } }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $commit = id(new DiffusionCommitQuery())->setViewer($this->getViewer())->withPHIDs(array($object->getPHID()))->needCommitData(true)->executeOne(); $repository = $commit->getRepository(); $commit_data = $commit->getCommitData(); $date_created = $commit->getEpoch(); $commit_message = $commit_data->getCommitMessage(); $author_phid = $commit_data->getCommitDetail('authorPHID'); $title = 'r' . $repository->getCallsign() . $commit->getCommitIdentifier() . ' ' . $commit_data->getSummary(); $document->setDocumentCreated($date_created)->setDocumentModified($date_created)->setDocumentTitle($title); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $commit_message); if ($author_phid) { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $author_phid, PhabricatorPeopleUserPHIDType::TYPECONST, $date_created); } $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY, $repository->getPHID(), PhabricatorRepositoryRepositoryPHIDType::TYPECONST, $date_created); }
protected function buildAbstractDocumentByPHID($phid) { $credential = $this->loadDocumentByPHID($phid); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($credential->getPHID()); $doc->setDocumentType(PassphraseCredentialPHIDType::TYPECONST); $doc->setDocumentTitle($credential->getName()); $doc->setDocumentCreated($credential->getDateCreated()); $doc->setDocumentModified($credential->getDateModified()); $doc->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $credential->getDescription()); $doc->addRelationship($credential->getIsDestroyed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $credential->getPHID(), PassphraseCredentialPHIDType::TYPECONST, time()); $this->indexTransactions($doc, new PassphraseCredentialTransactionQuery(), array($phid)); return $doc; }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $revision = id(new DifferentialRevisionQuery())->setViewer($this->getViewer())->withPHIDs(array($object->getPHID()))->needReviewerStatus(true)->executeOne(); // TODO: This isn't very clean, but custom fields currently rely on it. $object->attachReviewerStatus($revision->getReviewerStatus()); $document->setDocumentTitle($revision->getTitle()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $revision->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateCreated()); $document->addRelationship($revision->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $revision->getPHID(), DifferentialRevisionPHIDType::TYPECONST, PhabricatorTime::getNow()); // If a revision needs review, the owners are the reviewers. Otherwise, the // owner is the author (e.g., accepted, rejected, closed). $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW; if ($revision->getStatus() == $status_review) { $reviewers = $revision->getReviewerStatus(); $reviewers = mpull($reviewers, 'getReviewerPHID', 'getReviewerPHID'); if ($reviewers) { foreach ($reviewers as $phid) { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateModified()); // Bogus timestamp. } } else { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $revision->getPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateModified()); // Bogus timestamp. } } else { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $revision->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $revision->getDateCreated()); } }
public static function indexDocument(PhrictionDocument $document) { $content = $document->getContent(); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($document->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_WIKI); $doc->setDocumentTitle($content->getTitle()); // TODO: This isn't precisely correct, denormalize into the Document table? $doc->setDocumentCreated($content->getDateCreated()); $doc->setDocumentModified($content->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $content->getContent()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $content->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $content->getDateCreated()); self::reindexAbstractDocument($doc); }
protected function buildAbstractDocumentByPHID($phid) { $document = $this->loadDocumentByPHID($phid); $content = id(new PhrictionContent())->load($document->getContentID()); $document->attachContent($content); $content = $document->getContent(); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($document->getPHID()); $doc->setDocumentType(PhrictionDocumentPHIDType::TYPECONST); $doc->setDocumentTitle($content->getTitle()); // TODO: This isn't precisely correct, denormalize into the Document table? $doc->setDocumentCreated($content->getDateCreated()); $doc->setDocumentModified($content->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $content->getContent()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $content->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $content->getDateCreated()); $doc->addRelationship($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, $document->getPHID(), PhrictionDocumentPHIDType::TYPECONST, time()); return $doc; }
protected function buildAbstractDocumentByPHID($phid) { $user = $this->loadDocumentByPHID($phid); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($user->getPHID()); $doc->setDocumentType(PhabricatorPeopleUserPHIDType::TYPECONST); $doc->setDocumentTitle($user->getFullName()); $doc->setDocumentCreated($user->getDateCreated()); $doc->setDocumentModified($user->getDateModified()); $doc->addRelationship($user->isUserActivated() ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, $user->getPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, time()); return $doc; }
protected function buildAbstractDocumentByPHID($phid) { $task = $this->loadDocumentByPHID($phid); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($task->getPHID()); $doc->setDocumentType(ManiphestTaskPHIDType::TYPECONST); $doc->setDocumentTitle($task->getTitle()); $doc->setDocumentCreated($task->getDateCreated()); $doc->setDocumentModified($task->getDateModified()); $doc->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $task->getDescription()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $task->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $task->getDateCreated()); $doc->addRelationship($task->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $task->getPHID(), ManiphestTaskPHIDType::TYPECONST, time()); $this->indexTransactions($doc, new ManiphestTransactionQuery(), array($phid)); $owner = $task->getOwnerPHID(); if ($owner) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $owner, PhabricatorPeopleUserPHIDType::TYPECONST, time()); } else { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $task->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $task->getDateCreated()); } return $doc; }
public static function indexQuestion(PonderQuestion $question) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($question->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_QUES); $doc->setDocumentTitle($question->getTitle()); $doc->setDocumentCreated($question->getDateCreated()); $doc->setDocumentModified($question->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $question->getContent()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $question->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $question->getDateCreated()); $answers = $question->getAnswers(); $touches = array(); foreach ($answers as $comment) { if (strlen($comment->getContent())) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $comment->getContent()); } $author = $comment->getAuthorPHID(); $touches[$author] = $comment->getDateCreated(); } self::reindexAbstractDocument($doc); }
public static function indexUser(PhabricatorUser $user) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($user->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_USER); $doc->setDocumentTitle($user->getUserName() . ' (' . $user->getRealName() . ')'); $doc->setDocumentCreated($user->getDateCreated()); $doc->setDocumentModified($user->getDateModified()); // TODO: Index the blurbs from their profile or something? Probably not // actually useful... if (!$user->getIsDisabled()) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $user->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, time()); } self::reindexAbstractDocument($doc); }
protected function buildAbstractDocumentByPHID($phid) { $project = $this->loadDocumentByPHID($phid); $project->updateDatasourceTokens(); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($project->getPHID()); $doc->setDocumentType(PhabricatorProjectProjectPHIDType::TYPECONST); $doc->setDocumentTitle($project->getName()); $doc->setDocumentCreated($project->getDateCreated()); $doc->setDocumentModified($project->getDateModified()); $doc->addRelationship($project->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $project->getPHID(), PhabricatorProjectProjectPHIDType::TYPECONST, time()); // NOTE: This could be more full-featured, but for now we're mostly // interested in the side effects of indexing. return $doc; }
public static function indexUser(PhabricatorUser $user) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($user->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_USER); $doc->setDocumentTitle($user->getUserName() . '(' . $user->getRealName() . ')'); $doc->setDocumentCreated($user->getDateCreated()); $doc->setDocumentModified($user->getDateModified()); // TODO: Index the blurbs from their profile or something? Probably not // actually useful... PhabricatorSearchDocument::reindexAbstractDocument($doc); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $wiki = id(new PhrictionDocumentQuery())->setViewer($this->getViewer())->withPHIDs(array($document->getPHID()))->needContent(true)->executeOne(); $content = $wiki->getContent(); $document->setDocumentTitle($content->getTitle()); // TODO: These are not quite correct, but we don't currently store the // proper dates in a way that's easy to get to. $document->setDocumentCreated($content->getDateCreated())->setDocumentModified($content->getDateModified()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $content->getContent()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $content->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $content->getDateCreated()); $document->addRelationship($wiki->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, $wiki->getPHID(), PhrictionDocumentPHIDType::TYPECONST, PhabricatorTime::getNow()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $event = $object; $document->setDocumentTitle($event->getName()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $event->getDescription()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $event->getHostPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $event->getDateCreated()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $event->getHostPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $event->getDateCreated()); $document->addRelationship($event->getIsCancelled() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $event->getPHID(), PhabricatorCalendarEventPHIDType::TYPECONST, PhabricatorTime::getNow()); }
public static function indexCommit(PhabricatorRepositoryCommit $commit) { $commit_data = id(new PhabricatorRepositoryCommitData())->loadOneWhere('commitID = %d', $commit->getID()); $date_created = $commit->getEpoch(); $commit_message = $commit_data->getCommitMessage(); $author_phid = $commit_data->getCommitDetail('authorPHID'); $repository = id(new PhabricatorRepository())->loadOneWhere('id = %d', $commit->getRepositoryID()); if (!$repository) { return; } $title = 'r' . $repository->getCallsign() . $commit->getCommitIdentifier() . " " . $commit_data->getSummary(); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($commit->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_CMIT); $doc->setDocumentCreated($date_created); $doc->setDocumentModified($date_created); $doc->setDocumentTitle($title); $doc->addField(PhabricatorSearchField::FIELD_BODY, $commit_message); if ($author_phid) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $author_phid, PhabricatorPHIDConstants::PHID_TYPE_USER, $date_created); } $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY, $repository->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_REPO, $date_created); self::reindexAbstractDocument($doc); }