Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80645971
DifferentialSearchIndexer.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 1, 21:00
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Sep 3, 21:00 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20414394
Attached To
rPH Phabricator
DifferentialSearchIndexer.php
View Options
<?php
final
class
DifferentialSearchIndexer
extends
PhabricatorSearchDocumentIndexer
{
public
function
getIndexableObject
()
{
return
new
DifferentialRevision
();
}
protected
function
loadDocumentByPHID
(
$phid
)
{
$object
=
id
(
new
DifferentialRevisionQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withPHIDs
(
array
(
$phid
))
->
needReviewerStatus
(
true
)
->
executeOne
();
if
(!
$object
)
{
throw
new
Exception
(
"Unable to load object by phid '{$phid}'!"
);
}
return
$object
;
}
protected
function
buildAbstractDocumentByPHID
(
$phid
)
{
$rev
=
$this
->
loadDocumentByPHID
(
$phid
);
$doc
=
new
PhabricatorSearchAbstractDocument
();
$doc
->
setPHID
(
$rev
->
getPHID
());
$doc
->
setDocumentType
(
DifferentialRevisionPHIDType
::
TYPECONST
);
$doc
->
setDocumentTitle
(
$rev
->
getTitle
());
$doc
->
setDocumentCreated
(
$rev
->
getDateCreated
());
$doc
->
setDocumentModified
(
$rev
->
getDateModified
());
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_AUTHOR
,
$rev
->
getAuthorPHID
(),
PhabricatorPeopleUserPHIDType
::
TYPECONST
,
$rev
->
getDateCreated
());
$doc
->
addRelationship
(
$rev
->
isClosed
()
?
PhabricatorSearchRelationship
::
RELATIONSHIP_CLOSED
:
PhabricatorSearchRelationship
::
RELATIONSHIP_OPEN
,
$rev
->
getPHID
(),
DifferentialRevisionPHIDType
::
TYPECONST
,
time
());
$this
->
indexTransactions
(
$doc
,
new
DifferentialTransactionQuery
(),
array
(
$rev
->
getPHID
()));
// If a revision needs review, the owners are the reviewers. Otherwise, the
// owner is the author (e.g., accepted, rejected, closed).
if
(
$rev
->
getStatus
()
==
ArcanistDifferentialRevisionStatus
::
NEEDS_REVIEW
)
{
$reviewers
=
$rev
->
getReviewerStatus
();
$reviewers
=
mpull
(
$reviewers
,
'getReviewerPHID'
,
'getReviewerPHID'
);
if
(
$reviewers
)
{
foreach
(
$reviewers
as
$phid
)
{
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_OWNER
,
$phid
,
PhabricatorPeopleUserPHIDType
::
TYPECONST
,
$rev
->
getDateModified
());
// Bogus timestamp.
}
}
else
{
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_UNOWNED
,
$rev
->
getPHID
(),
PhabricatorPeopleUserPHIDType
::
TYPECONST
,
$rev
->
getDateModified
());
// Bogus timestamp.
}
}
else
{
$doc
->
addRelationship
(
PhabricatorSearchRelationship
::
RELATIONSHIP_OWNER
,
$rev
->
getAuthorPHID
(),
PhabricatorPHIDConstants
::
PHID_TYPE_VOID
,
$rev
->
getDateCreated
());
}
return
$doc
;
}
}
Event Timeline
Log In to Comment