diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3a5f3e41fa..ada15cb73b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -738,6 +738,7 @@ phutil_register_library_map(array( 'PhabricatorApplicationTransactions' => 'applications/transactions/application/PhabricatorApplicationTransactions.php', 'PhabricatorApplicationUIExamples' => 'applications/uiexample/application/PhabricatorApplicationUIExamples.php', 'PhabricatorApplicationUninstallController' => 'applications/meta/controller/PhabricatorApplicationUninstallController.php', + 'PhabricatorApplicationXHProf' => 'applications/xhprof/application/PhabricatorApplicationXHProf.php', 'PhabricatorApplicationsController' => 'applications/meta/controller/PhabricatorApplicationsController.php', 'PhabricatorApplicationsListController' => 'applications/meta/controller/PhabricatorApplicationsListController.php', 'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php', @@ -1473,7 +1474,6 @@ phutil_register_library_map(array( 'PhabricatorXHProfProfileView' => 'applications/xhprof/view/PhabricatorXHProfProfileView.php', 'PhabricatorXHProfSample' => 'applications/xhprof/storage/PhabricatorXHProfSample.php', 'PhabricatorXHProfSampleListController' => 'applications/xhprof/controller/PhabricatorXHProfSampleListController.php', - 'PhabricatorXHProfSampleListView' => 'applications/xhprof/view/PhabricatorXHProfSampleListView.php', 'PhameBasicBlogSkin' => 'applications/phame/skins/PhameBasicBlogSkin.php', 'PhameBasicTemplateBlogSkin' => 'applications/phame/skins/PhameBasicTemplateBlogSkin.php', 'PhameBlog' => 'applications/phame/storage/PhameBlog.php', @@ -2420,6 +2420,7 @@ phutil_register_library_map(array( 'PhabricatorApplicationTransactions' => 'PhabricatorApplication', 'PhabricatorApplicationUIExamples' => 'PhabricatorApplication', 'PhabricatorApplicationUninstallController' => 'PhabricatorApplicationsController', + 'PhabricatorApplicationXHProf' => 'PhabricatorApplication', 'PhabricatorApplicationsController' => 'PhabricatorController', 'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController', 'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController', @@ -3127,7 +3128,6 @@ phutil_register_library_map(array( 'PhabricatorXHProfProfileView' => 'AphrontView', 'PhabricatorXHProfSample' => 'PhabricatorXHProfDAO', 'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController', - 'PhabricatorXHProfSampleListView' => 'AphrontView', 'PhameBasicBlogSkin' => 'PhameBlogSkin', 'PhameBasicTemplateBlogSkin' => 'PhameBasicBlogSkin', 'PhameBlog' => diff --git a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php index de64e1efbf..0bfa53ca55 100644 --- a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php @@ -68,11 +68,6 @@ class AphrontDefaultApplicationConfiguration ), ), - '/xhprof/' => array( - 'list/(?P[^/]+)/' => 'PhabricatorXHProfSampleListController', - 'profile/(?P[^/]+)/' => 'PhabricatorXHProfProfileController', - ), - '/~/' => array( '' => 'DarkConsoleController', 'data/(?P[^/]+)/' => 'DarkConsoleDataController', diff --git a/src/applications/xhprof/application/PhabricatorApplicationXHProf.php b/src/applications/xhprof/application/PhabricatorApplicationXHProf.php new file mode 100644 index 0000000000..b6bd7a728b --- /dev/null +++ b/src/applications/xhprof/application/PhabricatorApplicationXHProf.php @@ -0,0 +1,36 @@ + array( + '' => 'PhabricatorXHProfSampleListController', + 'list/(?P[^/]+)/' => 'PhabricatorXHProfSampleListController', + 'profile/(?P[^/]+)/' => 'PhabricatorXHProfProfileController', + ), + ); + } + + +} diff --git a/src/applications/xhprof/controller/PhabricatorXHProfSampleListController.php b/src/applications/xhprof/controller/PhabricatorXHProfSampleListController.php index 88080c61b8..facd9d2c4c 100644 --- a/src/applications/xhprof/controller/PhabricatorXHProfSampleListController.php +++ b/src/applications/xhprof/controller/PhabricatorXHProfSampleListController.php @@ -6,11 +6,12 @@ final class PhabricatorXHProfSampleListController private $view; public function willProcessRequest(array $data) { - $this->view = $data['view']; + $this->view = idx($data, 'view', 'all'); } public function processRequest() { $request = $this->getRequest(); + $user = $request->getUser(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); @@ -39,7 +40,7 @@ final class PhabricatorXHProfSampleListController } $samples = id(new PhabricatorXHProfSample())->loadAllWhere( - '%Q ORDER BY dateCreated DESC LIMIT %d, %d', + '%Q ORDER BY id DESC LIMIT %d, %d', $clause, $pager->getOffset(), $pager->getPageSize() + 1); @@ -47,19 +48,46 @@ final class PhabricatorXHProfSampleListController $samples = $pager->sliceResults($samples); $pager->setURI($request->getRequestURI(), 'page'); - $table = new PhabricatorXHProfSampleListView(); - $table->setUser($request->getUser()); - $table->setSamples($samples); - $table->setShowType($show_type); + $list = new PhabricatorObjectItemListView(); + foreach ($samples as $sample) { + $file_phid = $sample->getFilePHID(); - $panel = new AphrontPanelView(); - $panel->setHeader('XHProf Samples'); - $panel->appendChild($table); - $panel->appendChild($pager); + $item = id(new PhabricatorObjectItemView()) + ->setObjectName($sample->getID()) + ->setHeader($sample->getRequestPath()) + ->setHref($this->getApplicationURI('profile/'.$file_phid.'/')) + ->addAttribute( + number_format($sample->getUsTotal())." \xCE\xBCs"); + + 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( - $panel, - array('title' => 'XHProf Samples')); + $list, + array( + 'title' => pht('XHProf Samples'), + 'device' => true, + 'dust' => true, + )); } } diff --git a/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php b/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php deleted file mode 100644 index c10f8eb3d7..0000000000 --- a/src/applications/xhprof/view/PhabricatorXHProfSampleListView.php +++ /dev/null @@ -1,78 +0,0 @@ -samples = $samples; - return $this; - } - - public function setShowType($show_type) { - $this->showType = $show_type; - } - - public function render() { - $rows = array(); - - if (!$this->user) { - throw new Exception("Call setUser() before rendering!"); - } - - $user_phids = mpull($this->samples, 'getUserPHID'); - $users = id(new PhabricatorObjectHandleData($user_phids)) - ->setViewer($this->getUser()) - ->loadObjects(); - foreach ($this->samples as $sample) { - $sample_link = phutil_tag( - 'a', - array( - 'href' => '/xhprof/profile/'.$sample->getFilePHID().'/', - ), - $sample->getFilePHID()); - if ($this->showType) { - if ($sample->getSampleRate() == 0) { - $sample_link .= ' (manual run)'; - } else { - $sample_link .= ' (sampled)'; - } - } - $rows[] = array( - $sample_link, - phabricator_datetime($sample->getDateCreated(), $this->user), - number_format($sample->getUsTotal())." \xCE\xBCs", - $sample->getHostname(), - $sample->getRequestPath(), - $sample->getController(), - idx($users, $sample->getUserPHID()), - ); - } - - $table = new AphrontTableView($rows); - $table->setHeaders( - array( - 'Sample', - 'Date', - 'Wall Time', - 'Hostname', - 'Request Path', - 'Controller', - 'User', - )); - $table->setColumnClasses( - array( - '', - '', - 'right', - 'wide wrap', - '', - '', - )); - - return $table->render(); - } - -}