Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96528952
PhabricatorXHProfSampleListController.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
Fri, Dec 27, 15:58
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Dec 29, 15:58 (1 d, 7 h)
Engine
blob
Format
Raw Data
Handle
23198874
Attached To
rPH Phabricator
PhabricatorXHProfSampleListController.php
View Options
<?php
final
class
PhabricatorXHProfSampleListController
extends
PhabricatorXHProfController
{
private
$view
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
view
=
idx
(
$data
,
'view'
,
'all'
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$pager
=
new
AphrontPagerView
();
$pager
->
setOffset
(
$request
->
getInt
(
'page'
));
switch
(
$this
->
view
)
{
case
'sampled'
:
$clause
=
'`sampleRate` > 0'
;
$show_type
=
false
;
break
;
case
'my-runs'
:
$clause
=
qsprintf
(
id
(
new
PhabricatorXHProfSample
())->
establishConnection
(
'r'
),
'`sampleRate` = 0 AND `userPHID` = %s'
,
$request
->
getUser
()->
getPHID
());
$show_type
=
false
;
break
;
case
'manual'
:
$clause
=
'`sampleRate` = 0'
;
$show_type
=
false
;
break
;
case
'all'
:
default
:
$clause
=
'1 = 1'
;
$show_type
=
true
;
break
;
}
$samples
=
id
(
new
PhabricatorXHProfSample
())->
loadAllWhere
(
'%Q ORDER BY id DESC LIMIT %d, %d'
,
$clause
,
$pager
->
getOffset
(),
$pager
->
getPageSize
()
+
1
);
$samples
=
$pager
->
sliceResults
(
$samples
);
$pager
->
setURI
(
$request
->
getRequestURI
(),
'page'
);
$list
=
new
PhabricatorObjectItemListView
();
foreach
(
$samples
as
$sample
)
{
$file_phid
=
$sample
->
getFilePHID
();
$item
=
id
(
new
PhabricatorObjectItemView
())
->
setObjectName
(
$sample
->
getID
())
->
setHeader
(
$sample
->
getRequestPath
())
->
setHref
(
$this
->
getApplicationURI
(
'profile/'
.
$file_phid
.
'/'
))
->
addAttribute
(
number_format
(
$sample
->
getUsTotal
()).
"
\x
CE
\x
BCs"
);
if
(
$sample
->
getController
())
{
$item
->
addAttribute
(
$sample
->
getController
());
}
$item
->
addAttribute
(
$sample
->
getHostName
());
$rate
=
$sample
->
getSampleRate
();
if
(
$rate
==
0
)
{
$item
->
addIcon
(
'flag-6'
,
pht
(
'Manual Run'
));
}
else
{
$item
->
addIcon
(
'flag-7'
,
pht
(
'Sampled (1/%d)'
,
$rate
));
}
$item
->
addIcon
(
'none'
,
phabricator_datetime
(
$sample
->
getDateCreated
(),
$user
));
$list
->
addItem
(
$item
);
}
$list
->
setPager
(
$pager
);
return
$this
->
buildStandardPageResponse
(
$list
,
array
(
'title'
=>
pht
(
'XHProf Samples'
),
'device'
=>
true
,
'dust'
=>
true
,
));
}
}
Event Timeline
Log In to Comment