'Rails Analyzer', 'pepperUrl' => 'http://nubyonrails.com/pages/mint', 'pepperDesc' => 'Shows a report of page request, db, and render times.', 'developerName' => 'Geoffrey Grosenbach', 'developerUrl' => 'http://nubyonrails.com/' ); var $panes = array ( 'Rails Analyzer' => array ( 'Request Times', 'Requests per Second' ) ); var $prefs = array ( 'src' => 'topfunky/rails_analyzer/', 'class' => 'Topfunky_Rails_Analyzer' ); var $manifest = array(); /************************************************************************** isCompatible() **************************************************************************/ function isCompatible() { return array ( 'isCompatible' => true, ); } /************************************************************************** onRecord() **************************************************************************/ function onRecord() { return array(); } /************************************************************************** onDisplay() **************************************************************************/ function onDisplay($pane,$tab,$column='',$sort='') { $html = ''; // Ug Lee Hak as recommended by SI $html .= << /* */ HERE; switch($pane) { /* Visitors ***********************************************************/ case 'Rails Analyzer': switch($tab) { /* Most Common ************************************************/ case 'Request Times': $html .= $this->getHTML_RailsRequestTimes(); break; /* Most Recent ************************************************/ case 'Requests per Second': $html .= $this->getHTML_RailsRequestsPerSecond(); break; } break; } return $html; } // onDisplay /************************************************************************** onDisplayPreferences() **************************************************************************/ function onDisplayPreferences() { $preferences['Rails Analyzer'] = ""; return $preferences; } /************************************************************************** getHTML_RailsRequestTimes **************************************************************************/ function getHTML_RailsRequestTimes() { return $this->getResultsForClass('Request Time', 'MintAnalyzeRequestTime', 'inline-foot topfunky_rails_analyzer', true) . $this->getResultsForClass('Database Time', 'MintAnalyzeDBTime', 'inline-foot topfunky_rails_analyzer', true) . $this->getResultsForClass('Render Time', 'MintAnalyzeRenderTime', 'inline topfunky_rails_analyzer', true); } function getResultsForClass($column_label, $klass_name, $css_class_name, $show_as_float) { unset($tableData); $tableData['table'] = array('id'=>'','class'=>$css_class_name); $tableData['thead'] = array( // display name, CSS class(es) for each column array('value'=>$column_label,'class'=>'stacked-rows'), array('value'=>'Count','class'=>''), array('value'=>'Average','class'=>''), array('value'=>'Std Dev','class'=>''), array('value'=>'Min','class'=>''), array('value'=>'Max','class'=>'') ); $query = "SELECT resource, visit_count, average, standard_deviation, min, max FROM `mint_analyze` WHERE DAY(`created_at`) = DAY(NOW()) AND MONTH(`created_at`) = MONTH(NOW()) AND YEAR(`created_at`) = YEAR(NOW()) AND `type` = '$klass_name' ORDER BY `visit_count` DESC "; $format = "%01.3f"; if ($result = mysql_query($query)) { while ($r = mysql_fetch_array($result)) { if ($show_as_float) { $tableData['tbody'][] = array($r['resource'], $r['visit_count'], sprintf($format, $r['average']), sprintf($format, $r['standard_deviation']), sprintf($format, $r['min']), sprintf($format, $r['max']) ); } else { // min and max are swapped to be relevant $tableData['tbody'][] = array($r['resource'], $r['visit_count'], $this->toRequestsPerSecond($r['average']), $this->toRequestsPerSecond($r['standard_deviation']), $this->toRequestsPerSecond($r['max']), $this->toRequestsPerSecond($r['min']) ); } } } else { $tableData['tbody'][] = array('No data', 0,0,0,0,0); } return $this->Mint->generateTable($tableData); } function toRequestsPerSecond($floatval) { if ($floatval > 0) { return sprintf('%d', 1.0/$floatval); } else { return '∞'; } } // getResultsForClass /************************************************************************** getHTML_RailsRequestsPerSecond **************************************************************************/ function getHTML_RailsRequestsPerSecond() { return $this->getResultsForClass('Request Time', 'MintAnalyzeRequestTime', 'inline-foot topfunky_rails_analyzer', false) . $this->getResultsForClass('Database Time', 'MintAnalyzeDBTime', 'inline-foot topfunky_rails_analyzer', false) . $this->getResultsForClass('Render Time', 'MintAnalyzeRenderTime', 'inline topfunky_rails_analyzer', false); } } // class Topfunky_Rails_Analyzer