Differential D17401 Diff 41840 src/applications/xhprof/query/PhabricatorXHProfSampleSearchEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/xhprof/query/PhabricatorXHProfSampleSearchEngine.php
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | protected function renderResultList( | ||||
$viewer = $this->requireViewer(); | $viewer = $this->requireViewer(); | ||||
$list = new PHUIObjectItemListView(); | $list = new PHUIObjectItemListView(); | ||||
foreach ($samples as $sample) { | foreach ($samples as $sample) { | ||||
$file_phid = $sample->getFilePHID(); | $file_phid = $sample->getFilePHID(); | ||||
$item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
->setObjectName($sample->getID()) | ->setObjectName($sample->getID()) | ||||
->setHeader($sample->getRequestPath()) | ->setHeader($sample->getDisplayName()) | ||||
->setHref($this->getApplicationURI('profile/'.$file_phid.'/')) | ->setHref($sample->getURI()); | ||||
->addAttribute( | |||||
number_format($sample->getUsTotal())." \xCE\xBCs"); | $us_total = $sample->getUsTotal(); | ||||
if ($us_total) { | |||||
$item->addAttribute(pht("%s \xCE\xBCs", new PhutilNumber($us_total))); | |||||
} | |||||
if ($sample->getController()) { | if ($sample->getController()) { | ||||
$item->addAttribute($sample->getController()); | $item->addAttribute($sample->getController()); | ||||
} | } | ||||
$item->addAttribute($sample->getHostName()); | $item->addAttribute($sample->getHostName()); | ||||
$rate = $sample->getSampleRate(); | $rate = $sample->getSampleRate(); | ||||
if ($rate == 0) { | if ($rate == 0) { | ||||
$item->addIcon('flag-6', pht('Manual Run')); | $item->addIcon('flag-6', pht('Manual Run')); | ||||
} else { | } else { | ||||
$item->addIcon('flag-7', pht('Sampled (1/%d)', $rate)); | $item->addIcon('flag-7', pht('Sampled (1/%d)', $rate)); | ||||
} | } | ||||
$item->addIcon( | $item->addIcon( | ||||
'none', | 'none', | ||||
phabricator_datetime($sample->getDateCreated(), $viewer)); | phabricator_datetime($sample->getDateCreated(), $viewer)); | ||||
$list->addItem($item); | $list->addItem($item); | ||||
} | } | ||||
$result = new PhabricatorApplicationSearchResultView(); | return $this->newResultView() | ||||
$result->setObjectList($list); | ->setObjectList($list); | ||||
} | |||||
private function newResultView($content = null) { | |||||
// If we aren't rendering a dashboard panel, activate global drag-and-drop | |||||
// so you can import profiles by dropping them into the list. | |||||
if (!$this->isPanelContext()) { | |||||
$drop_upload = id(new PhabricatorGlobalUploadTargetView()) | |||||
->setViewer($this->requireViewer()) | |||||
->setHintText("\xE2\x87\xAA ".pht('Drop .xhprof Files to Import')) | |||||
->setSubmitURI('/xhprof/import/drop/') | |||||
->setViewPolicy(PhabricatorPolicies::POLICY_NOONE); | |||||
$content = array( | |||||
$drop_upload, | |||||
$content, | |||||
); | |||||
} | |||||
return $result; | return id(new PhabricatorApplicationSearchResultView()) | ||||
->setContent($content); | |||||
} | } | ||||
} | } |