1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

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
This commit is contained in:
epriestley 2013-09-23 14:29:31 -07:00
parent 7abe9dc4c0
commit 77475736a3

View file

@ -38,39 +38,10 @@ final class ManiphestSearchIndexer
time()); time());
} }
$transactions = ManiphestLegacyTransactionQuery::loadByTask( $this->indexTransactions(
$this->getViewer(), $doc,
$task); new ManiphestTransactionQuery(),
array($phid));
$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;
}
}
foreach ($task->getProjectPHIDs() as $phid) { foreach ($task->getProjectPHIDs() as $phid) {
$doc->addRelationship( $doc->addRelationship(
@ -80,12 +51,13 @@ final class ManiphestSearchIndexer
$task->getDateModified()); // Bogus. $task->getDateModified()); // Bogus.
} }
if ($owner && $owner->getNewValue()) { $owner = $task->getOwnerPHID();
if ($owner) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$owner->getNewValue(), $owner,
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPeoplePHIDTypeUser::TYPECONST,
$owner->getDateCreated()); time());
} else { } else {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
@ -98,16 +70,17 @@ final class ManiphestSearchIndexer
// We need to load handles here since non-users may subscribe (mailing // We need to load handles here since non-users may subscribe (mailing
// lists, e.g.) // lists, e.g.)
$ccs = $task->getCCPHIDs();
$handles = id(new PhabricatorHandleQuery()) $handles = id(new PhabricatorHandleQuery())
->setViewer(PhabricatorUser::getOmnipotentUser()) ->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs(array_keys($ccs)) ->withPHIDs($ccs)
->execute(); ->execute();
foreach ($ccs as $cc => $time) { foreach ($ccs as $cc) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,
$handles[$cc]->getPHID(), $handles[$cc]->getPHID(),
$handles[$cc]->getType(), $handles[$cc]->getType(),
$time); time());
} }
return $doc; return $doc;