mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +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:
parent
7abe9dc4c0
commit
77475736a3
1 changed files with 12 additions and 39 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue