<?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,
      $book->getDateCreated());

    return $doc;
  }

}

<?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(
      $atom->getGraphHash()
        ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
        : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
      $atom->getBookPHID(),
      DivinerBookPHIDType::TYPECONST,
      PhabricatorTime::getNow());

    return $doc;
  }

}

Mark diviner atoms as closed in search index
Mark diviner atoms as closed in search index

Summary: Ref T4558. If a Diviner atom is a ghost (i.e. the underlying source code has been removed), mark it as closed in the search index.

Test Plan: Searched for a ghost atom in global searcn and saw the results show "Closed".

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T4558

Differential Revision: https://secure.phabricator.com/D13297
