From 128dfa11a30d4d5d7ecddca442e761651589bc47 Mon Sep 17 00:00:00 2001 From: Robert Helmer Date: Wed, 23 Nov 2011 17:49:24 -0800 Subject: [PATCH] bug 701156 - simplify newreport example per schalk and lonnen --- docs/ui.rst | 251 ++++++---------------------------------------------- 1 file changed, 28 insertions(+), 223 deletions(-) diff --git a/docs/ui.rst b/docs/ui.rst index cdd35d4848..56034c2e49 100644 --- a/docs/ui.rst +++ b/docs/ui.rst @@ -70,32 +70,15 @@ Model ^^^^^ webapp-php/application/models/newreport.php +See :ref:`addaservice-chapter` for details about writing a middleware service for +this to use. + .. code-block:: php - get("${host}/reports/new/p/${p}/v/${v}/end/${end_date}/duration/${duration}/listsize/${limit}/page/${pg}"); - if($resp) { - return $resp; - } - return false; + public function getNewReportViaWebService() { + // this should be pulled from the middleware service } } ?> @@ -107,93 +90,15 @@ webapp-php/application/views/newreport/byversion.php .. code-block:: html+php - New Report for <?php out::H($product) ?> <?php out::H($version) ?> - New Report for + - - - -
-

New Report for

- - -
- - -
-
- - - - - - - - - - - - render(TRUE); - foreach ($resp->newReport as $entry) { - $sigParams = array( - 'date' => $entry->report_day, - 'signature' => $entry->browser_signature - ); - if (property_exists($entry, 'branch')) { - $sigParams['branch'] = $entry->branch; - } else { - $sigParams['version'] = $product . ':' . $version; - } - - $browser_link_url = url::base() . 'report/list?' . html::query_string($sigParams); - $sigParams['signature'] = $entry->plugin_signature; - $plugin_link_url = url::base() . 'report/list?' . html::query_string($sigParams); - $uuid_link_url = url::base() . 'report/index/' . $entry->uuid; - ?> - - - - - - - - - -
Browser SignaturePlugin SignatureFlash VersionOOIDReport Day
- browser_signature) ?> - - plugin_signature) ?> - - flash_version) ?> - - uuid) ?> - - report_day) ?> -
- render(TRUE); - } else { - View::factory('common/data_access_error')->render(TRUE); - } - ?> -
-
- ?> + Controller ^^^^^^^^^^ @@ -202,133 +107,33 @@ webapp-php/application/controllers/newreport.php .. code-block:: php newreport_model = new NewReport_Model(); - } - - private function _versionExists($version) { - if (!$this->versionExists($version)) { - Kohana::show_404(); - } } - + + // Public functions map to routes on the controller + // http:///NewReport/index/[product, version, ?'foo'='bar', etc] public function index() { - $products = $this->featured_versions; - $product = null; - - if(empty($products)) { - Kohana::show_404(); - } - - foreach($products as $individual) { - if($individual->release == 'major') { - $product = $individual; - } - } - - if(empty($product)) { - $product = array_shift($products); - } - - return url::redirect('/newreport/byversion/' . $product->product); - } - - public function byversion($product=null, $version=null) - { - if(is_null($product)) { - Kohana::show_404(); - } - $this->navigationChooseVersion($product, $version); - if (empty($version)) { - $this->_handleEmptyVersion($product, 'byversion'); - } else { - $this->_versionExists($version); - } - - $duration = (int)Input::instance()->get('duration'); - if (empty($duration)) { - $duration = Kohana::config('products.duration'); - } - - $page = (int)Input::instance()->get('page'); - $page = (!empty($page) && $page > 0) ? $page : 1; - - $config = array(); - $credentials = Kohana::config('webserviceclient.basic_auth'); - if ($credentials) { - $config['basic_auth'] = $credentials; - } - $service = new Web_Service($config); - - $host = Kohana::config('webserviceclient.socorro_hostname'); - - $cache_in_minutes = Kohana::config('webserviceclient.new_report_cache_minutes', 60); - $end_date = urlencode(date('Y-m-d\TH:i:s\T+0000', TimeUtil::roundOffByMinutes($cache_in_minutes))); - $limit = Kohana::config('new_report.byversion_limit', 300); - // lifetime in seconds - $lifetime = $cache_in_minutes * 60; - - $p = urlencode($product); - $v = urlencode($version); - $pg = urlencode($page); - $resp = $this->newreport_model->getNewReportViaWebService($p, $v, $duration, $pg); - + $resp = $this->newreport_model->getNewReportViaWebService(); if ($resp) { - $pager = new MozPager(Kohana::config('new_report.byversion_limit'), $resp->totalCount, $resp->currentPage); - $this->setViewData(array( - 'resp' => $resp, - 'duration' => $duration, - 'product' => $product, - 'version' => $version, - 'nav_selection' => 'new_report', - 'end_date' => $resp->endDate, - 'url_base' => url::site('newreport/byversion/'.$product.'/'.$version), - 'url_nav' => url::site('products/'.$product), - 'pager' => $pager, - 'totalItemText' => " Results", - 'navPathPrefix' => url::site('newreport/byversion/'.$product.'/'.$version) . '?duration=' . $duration . '&page=', + 'resp' => $resp, + 'nav_selection' => 'new_report', + 'foo' => $resp->foo, )); } else { header("Data access error", TRUE, 500); - $this->setViewData( - array( - 'nav_selection' => 'top_crashes', - 'product' => $product, - 'url_nav' => url::site('products/'.$product), - 'version' => $version, - 'resp' => $resp - ) - ); - } - } - - private function _handleEmptyVersion($product, $method) { - $product_version = $this->branch_model->getRecentProductVersion($product); - if (empty($product_version)) { - // If no current major versions are found, grab any available version - $product_versions = $this->branch_model->getCurrentProductVersionsByProduct($product); - if (isset($product_versions[0])) { - $product_version = array_shift($product_versions); - } + $this->setViewData(array( + 'resp' => $resp, + 'nav_selection' => 'new_report', + )); } - - $version = $product_version->version; - $this->chooseVersion( - array( - 'product' => $product, - 'version' => $version, - 'release' => null - ) - ); - - url::redirect('newreport/'.$method.'/'.$product.'/'.$version); } + } ?>