From 77475736a34d0fa08b1691a6129c273a3908eb4a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Sep 2013 14:29:31 -0700 Subject: [PATCH] Switch Maniphest search indexing to real ApplicationTransactions Summary: Ref T2217. Move this off `LegacyQuery` and on to the real deal. The rest of this patch mostly just replaces some gymnastics to get accurate-ish timestamps for CCs/Owners with `time()`. The search feature where edge time is stored was never really used and isn't necessarily of much value -- most indexers don't bother computing it exactly, and possibly we should get rid of it entirely. If it surfaces in the product again at some point, it's easy enough to make the time data more accurate and reindex. Test Plan: Ran `bin/search index T12`, etc. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217 Differential Revision: https://secure.phabricator.com/D7069 --- .../search/ManiphestSearchIndexer.php | 51 +++++-------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/src/applications/maniphest/search/ManiphestSearchIndexer.php b/src/applications/maniphest/search/ManiphestSearchIndexer.php index 5977cc357a..5d8fc96a6b 100644 --- a/src/applications/maniphest/search/ManiphestSearchIndexer.php +++ b/src/applications/maniphest/search/ManiphestSearchIndexer.php @@ -38,39 +38,10 @@ final class ManiphestSearchIndexer time()); } - $transactions = ManiphestLegacyTransactionQuery::loadByTask( - $this->getViewer(), - $task); - - $current_ccs = $task->getCCPHIDs(); - $owner = null; - $ccs = array(); - foreach ($transactions as $transaction) { - if ($transaction->hasComments()) { - $doc->addField( - PhabricatorSearchField::FIELD_COMMENT, - $transaction->getComments()); - } - - $author = $transaction->getAuthorPHID(); - - switch ($transaction->getTransactionType()) { - case ManiphestTransactionType::TYPE_OWNER: - $owner = $transaction; - break; - case ManiphestTransactionType::TYPE_CCS: - // For users who are still CC'd, record the first time they were - // added to CC. - foreach ($transaction->getNewValue() as $added_cc) { - if (in_array($added_cc, $current_ccs)) { - if (empty($ccs[$added_cc])) { - $ccs[$added_cc] = $transaction->getDateCreated(); - } - } - } - break; - } - } + $this->indexTransactions( + $doc, + new ManiphestTransactionQuery(), + array($phid)); foreach ($task->getProjectPHIDs() as $phid) { $doc->addRelationship( @@ -80,12 +51,13 @@ final class ManiphestSearchIndexer $task->getDateModified()); // Bogus. } - if ($owner && $owner->getNewValue()) { + $owner = $task->getOwnerPHID(); + if ($owner) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, - $owner->getNewValue(), + $owner, PhabricatorPeoplePHIDTypeUser::TYPECONST, - $owner->getDateCreated()); + time()); } else { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, @@ -98,16 +70,17 @@ final class ManiphestSearchIndexer // 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(array_keys($ccs)) + ->withPHIDs($ccs) ->execute(); - foreach ($ccs as $cc => $time) { + foreach ($ccs as $cc) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, $handles[$cc]->getPHID(), $handles[$cc]->getType(), - $time); + time()); } return $doc;