3 final class PhabricatorXHProfSampleSearchEngine
4 extends PhabricatorApplicationSearchEngine
{
6 public function getResultTypeDescription() {
7 return pht('XHProf Samples');
10 public function getApplicationClassName() {
11 return 'PhabricatorXHProfApplication';
14 public function newQuery() {
15 return id(new PhabricatorXHProfSampleQuery());
18 protected function buildQueryFromParameters(array $map) {
19 $query = $this->newQuery();
24 protected function buildCustomSearchFields() {
28 protected function getURI($path) {
29 return '/xhprof/'.$path;
32 protected function getBuiltinQueryNames() {
34 'all' => pht('All Samples'),
40 public function buildSavedQueryFromBuiltin($query_key) {
41 $query = $this->newSavedQuery();
42 $query->setQueryKey($query_key);
49 return parent
::buildSavedQueryFromBuiltin($query_key);
52 protected function renderResultList(
54 PhabricatorSavedQuery
$query,
56 assert_instances_of($samples, 'PhabricatorXHProfSample');
58 $viewer = $this->requireViewer();
60 $list = new PHUIObjectItemListView();
61 foreach ($samples as $sample) {
62 $file_phid = $sample->getFilePHID();
64 $item = id(new PHUIObjectItemView())
65 ->setObjectName($sample->getID())
66 ->setHeader($sample->getDisplayName())
67 ->setHref($sample->getURI());
69 $us_total = $sample->getUsTotal();
71 $item->addAttribute(pht("%s \xCE\xBCs", new PhutilNumber($us_total)));
74 if ($sample->getController()) {
75 $item->addAttribute($sample->getController());
78 $item->addAttribute($sample->getHostName());
80 $rate = $sample->getSampleRate();
82 $item->addIcon('flag-6', pht('Manual Run'));
84 $item->addIcon('flag-7', pht('Sampled (1/%d)', $rate));
89 phabricator_datetime($sample->getDateCreated(), $viewer));
91 $list->addItem($item);
94 return $this->newResultView()
95 ->setObjectList($list);
99 private function newResultView($content = null) {
100 // If we aren't rendering a dashboard panel, activate global drag-and-drop
101 // so you can import profiles by dropping them into the list.
103 if (!$this->isPanelContext()) {
104 $drop_upload = id(new PhabricatorGlobalUploadTargetView())
105 ->setViewer($this->requireViewer())
106 ->setHintText("\xE2\x87\xAA ".pht('Drop .xhprof Files to Import'))
107 ->setSubmitURI('/xhprof/import/drop/')
108 ->setViewPolicy(PhabricatorPolicies
::POLICY_NOONE
);
116 return id(new PhabricatorApplicationSearchResultView())
117 ->setContent($content);