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) { $project = $object; $project->updateDatasourceTokens(); $document->setDocumentTitle($project->getName()); $document->addRelationship($project->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $project->getPHID(), PhabricatorProjectProjectPHIDType::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); $comments = id(new PhabricatorAuditComment())->loadAllWhere('targetPHID = %s', $commit->getPHID()); foreach ($comments as $comment) { if (strlen($comment->getContent())) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $comment->getContent()); } } self::reindexAbstractDocument($doc); }
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) { $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 indexQuestion(PonderQuestion $question) { // note: we assume someone's already called attachrelated on $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()); $comments = $question->getComments(); foreach ($comments as $curcomment) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $curcomment->getContent()); } $answers = $question->getAnswers(); foreach ($answers as $curanswer) { if (strlen($curanswer->getContent())) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $curanswer->getContent()); } $answer_comments = $curanswer->getComments(); foreach ($answer_comments as $curcomment) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $curcomment->getContent()); } } self::reindexAbstractDocument($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()); }
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; }
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) { $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) { $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) { $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) { $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) { $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 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()); }
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $atom = $object; $book = $atom->getBook(); $document->setDocumentTitle($atom->getTitle())->setDocumentCreated($book->getDateCreated())->setDocumentModified($book->getDateModified()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $atom->getSummary()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_BOOK, $atom->getBookPHID(), DivinerBookPHIDType::TYPECONST, PhabricatorTime::getNow()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY, $atom->getRepositoryPHID(), PhabricatorRepositoryRepositoryPHIDType::TYPECONST, PhabricatorTime::getNow()); $document->addRelationship($atom->getGraphHash() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $atom->getBookPHID(), DivinerBookPHIDType::TYPECONST, PhabricatorTime::getNow()); }
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 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) { $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; }
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 buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object) { $task = $object; $document->setDocumentTitle($task->getTitle()); $document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $task->getDescription()); $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $task->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $task->getDateCreated()); $document->addRelationship($task->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $task->getPHID(), ManiphestTaskPHIDType::TYPECONST, PhabricatorTime::getNow()); $owner = $task->getOwnerPHID(); if ($owner) { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $owner, PhabricatorPeopleUserPHIDType::TYPECONST, time()); } else { $document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $task->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $task->getDateCreated()); } }
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; }
protected function buildAbstractDocumentByPHID($phid) { $event = $this->loadDocumentByPHID($phid); $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($event->getPHID()); $doc->setDocumentType(PhabricatorCalendarEventPHIDType::TYPECONST); $doc->setDocumentTitle($event->getName()); $doc->setDocumentCreated($event->getDateCreated()); $doc->setDocumentModified($event->getDateModified()); $doc->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $event->getDescription()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $event->getUserPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $event->getDateCreated()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $event->getUserPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $event->getDateCreated()); $doc->addRelationship($event->getIsCancelled() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $event->getPHID(), PhabricatorCalendarEventPHIDType::TYPECONST, time()); $this->indexTransactions($doc, new PhabricatorCalendarEventTransactionQuery(), array($phid)); return $doc; }
public static function indexRevision(DifferentialRevision $rev) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($rev->getPHID()); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_DREV); $doc->setDocumentTitle($rev->getTitle()); $doc->setDocumentCreated($rev->getDateCreated()); $doc->setDocumentModified($rev->getDateModified()); $doc->addField(PhabricatorSearchField::FIELD_BODY, $rev->getSummary()); $doc->addField(PhabricatorSearchField::FIELD_TEST_PLAN, $rev->getTestPlan()); $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $rev->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateCreated()); if ($rev->getStatus() != ArcanistDifferentialRevisionStatus::CLOSED && $rev->getStatus() != ArcanistDifferentialRevisionStatus::ABANDONED) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $rev->getPHID(), PhabricatorPHIDConstants::PHID_TYPE_DREV, time()); } $comments = id(new DifferentialComment())->loadAllWhere('revisionID = %d', $rev->getID()); $inlines = id(new DifferentialInlineComment())->loadAllWhere('revisionID = %d AND commentID IS NOT NULL', $rev->getID()); $touches = array(); foreach (array_merge($comments, $inlines) as $comment) { if (strlen($comment->getContent())) { $doc->addField(PhabricatorSearchField::FIELD_COMMENT, $comment->getContent()); } $author = $comment->getAuthorPHID(); $touches[$author] = $comment->getDateCreated(); } foreach ($touches as $touch => $time) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, $touch, PhabricatorPHIDConstants::PHID_TYPE_USER, $time); } $rev->loadRelationships(); // 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) { foreach ($rev->getReviewers() as $phid) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateModified()); // Bogus timestamp. } } else { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $rev->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateCreated()); } $ccphids = $rev->getCCPHIDs(); $handles = id(new PhabricatorObjectHandleData($ccphids))->loadHandles(); foreach ($handles as $phid => $handle) { $doc->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $phid, $handle->getType(), $rev->getDateModified()); // Bogus timestamp. } 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) { $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 function reconstructDocument($phid) { $type = phid_get_type($phid); $response = $this->executeRequest("/phabricator/{$type}/{$phid}", array()); if (empty($response['exists'])) { return null; } $hit = $response['_source']; $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($phid); $doc->setDocumentType($response['_type']); $doc->setDocumentTitle($hit['title']); $doc->setDocumentCreated($hit['dateCreated']); $doc->setDocumentModified($hit['_timestamp']); foreach ($hit['field'] as $fdef) { $doc->addField($fdef['type'], $fdef['corpus'], $fdef['aux']); } foreach ($hit['relationship'] as $rtype => $rships) { foreach ($rships as $rship) { $doc->addRelationship($rtype, $rship['phid'], $rship['phidType'], $rship['when']); } } return $doc; }