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

Index "Closed" and "Unowned" relationships explicitly

Summary: Ref T4365. Two diffs from now, I'm changing the UI a bit to let you search for closed and unowned documents more explcitly. To support this in ElasticSearch and more easily in MySQL search, make these explicit, positive relationships.

Test Plan: `bin/search index --all`

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4365

Differential Revision: https://secure.phabricator.com/D8122
This commit is contained in:
epriestley 2014-02-03 12:51:18 -08:00
parent a48128d36f
commit e7d671c8d3
5 changed files with 47 additions and 38 deletions

View file

@ -44,13 +44,13 @@ final class DifferentialSearchIndexer
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPeoplePHIDTypeUser::TYPECONST,
$rev->getDateCreated()); $rev->getDateCreated());
if (!$rev->isClosed()) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $rev->isClosed()
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$rev->getPHID(), $rev->getPHID(),
DifferentialPHIDTypeRevision::TYPECONST, DifferentialPHIDTypeRevision::TYPECONST,
time()); time());
}
$comments = id(new DifferentialCommentQuery()) $comments = id(new DifferentialCommentQuery())
->withRevisionIDs(array($rev->getID())) ->withRevisionIDs(array($rev->getID()))
@ -74,18 +74,27 @@ final class DifferentialSearchIndexer
// If a revision needs review, the owners are the reviewers. Otherwise, the // If a revision needs review, the owners are the reviewers. Otherwise, the
// owner is the author (e.g., accepted, rejected, closed). // owner is the author (e.g., accepted, rejected, closed).
if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) { if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) {
foreach ($rev->getReviewers() as $phid) { $reviewers = $rev->getReviewers();
if ($reviewers) {
foreach ($reviewers as $phid) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$phid, $phid,
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPeoplePHIDTypeUser::TYPECONST,
$rev->getDateModified()); // Bogus timestamp. $rev->getDateModified()); // Bogus timestamp.
} }
} else {
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED,
$rev->getPHID(),
PhabricatorPeoplePHIDTypeUser::TYPECONST,
$rev->getDateModified()); // Bogus timestamp.
}
} else { } else {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$rev->getAuthorPHID(), $rev->getAuthorPHID(),
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPHIDConstants::PHID_TYPE_VOID,
$rev->getDateCreated()); $rev->getDateCreated());
} }

View file

@ -30,13 +30,13 @@ final class ManiphestSearchIndexer
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPeoplePHIDTypeUser::TYPECONST,
$task->getDateCreated()); $task->getDateCreated());
if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OPEN, ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN)
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
: PhabricatorSearchRelationship::RELATIONSHIP_CLOSED,
$task->getPHID(), $task->getPHID(),
ManiphestPHIDTypeTask::TYPECONST, ManiphestPHIDTypeTask::TYPECONST,
time()); time());
}
$this->indexTransactions( $this->indexTransactions(
$doc, $doc,
@ -60,12 +60,10 @@ final class ManiphestSearchIndexer
time()); time());
} else { } else {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED,
ManiphestTaskOwner::OWNER_UP_FOR_GRABS, $task->getPHID(),
PhabricatorPHIDConstants::PHID_TYPE_MAGIC, PhabricatorPHIDConstants::PHID_TYPE_VOID,
$owner $task->getDateCreated());
? $owner->getDateCreated()
: $task->getDateCreated());
} }
// We need to load handles here since non-users may subscribe (mailing // We need to load handles here since non-users may subscribe (mailing

View file

@ -20,13 +20,13 @@ final class PhabricatorUserSearchIndexer
// TODO: Index the blurbs from their profile or something? Probably not // TODO: Index the blurbs from their profile or something? Probably not
// actually useful... // actually useful...
if ($user->isUserActivated()) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $user->isUserActivated()
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
: PhabricatorSearchRelationship::RELATIONSHIP_CLOSED,
$user->getPHID(), $user->getPHID(),
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPeoplePHIDTypeUser::TYPECONST,
time()); time());
}
return $doc; return $doc;
} }

View file

@ -37,13 +37,13 @@ final class PhrictionSearchIndexer
PhabricatorPeoplePHIDTypeUser::TYPECONST, PhabricatorPeoplePHIDTypeUser::TYPECONST,
$content->getDateCreated()); $content->getDateCreated());
if ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OPEN, ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS)
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
: PhabricatorSearchRelationship::RELATIONSHIP_CLOSED,
$document->getPHID(), $document->getPHID(),
PhrictionPHIDTypeDocument::TYPECONST, PhrictionPHIDTypeDocument::TYPECONST,
time()); time());
}
return $doc; return $doc;
} }

View file

@ -14,5 +14,7 @@ final class PhabricatorSearchRelationship {
const RELATIONSHIP_REPOSITORY = 'repo'; const RELATIONSHIP_REPOSITORY = 'repo';
const RELATIONSHIP_OPEN = 'open'; const RELATIONSHIP_OPEN = 'open';
const RELATIONSHIP_CLOSED = 'clos';
const RELATIONSHIP_UNOWNED = 'unow';
} }