Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106109759
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
Sat, Mar 22, 13:07
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Mar 24, 13:07 (2 d)
Engine
blob
Format
Raw Data
Handle
25103670
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
(
pht
(
"Unable to load object by PHID '%s'!"
,
$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