} // Show button $buttons = <<<HTML <div style="float: right; margin-right: 100px;"> <a class="button" href="javascript:setStatusAndGo('issue_id', 'STATE_FIXED', '../reports/');">mark as fixed</a> <a class="button" href="javascript:setStatusAndGo('issue_id', 'STATE_INVALID', '../reports/');">mark as invalid</a> <a class="button" href="javascript:setStatusAndGo('issue_id', 'STATE_NEW', '../reports/');">mark as new</a> </div> <div style="display: block"><p> </p></div> HTML; echo str_replace(array("STATE_FIXED", "STATE_INVALID", "STATE_NEW", "issue_id"), array(STATE_FIXED, STATE_INVALID, STATE_NEW, $_GET['issue_id']), $buttons); // Display Android Versions pie chart display_crashes_vs_android_versions_pie_chart($_GET[issue_id]); display_crashes_vs_app_versions_pie_chart($_GET[issue_id]); // Display reports $sql = bicou_mysql_select(null, "crashes", "issue_id = ?", array($_GET[issue_id])); $sql .= " LIMIT 0, " . MAX_REPORTS; $res = mysql_query($sql); if (!$res) { bicou_log("Unable to query: {$sql}"); echo "<p>Server error.</p>\n"; return; } echo "<p>" . mysql_num_rows($res) . " crashes match the issue ID #" . $_GET[issue_id] . "</p>\n"; $first = true; while ($tab = mysql_fetch_assoc($res)) { if ($first) { $first = false; } else { echo '<hr style="height: 2px;color: #EEEEEE; width: 95%; clear:both;"/>'; }
* Copyright 2013 Benoit Duffez * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ include "crashes.php"; include "mysql.php"; $field = $_GET[field] == 'overview' ? "stack_trace" : $_GET[field]; // Display reports $sql = bicou_mysql_select(array($field), "crashes", "id = ?", array($_GET[id]), null, null, "0, 100"); $res = mysql_query($sql); if (!$res) { bicou_log("Unable to query: {$sql}"); echo "<p>Server error.</p>\n"; return; } $tab = mysql_fetch_assoc($res); if ($_GET[field] == 'overview') { $tab[$field] = "<ul><li>" . str_replace("<br />", "</li><li>", bicou_stack_trace_overview($tab[$field], null)) . "</li></ul>"; $tab[$field] = str_replace("<li></li>", "", $tab[$field]); } echo '<pre>' . $tab[$field] . '</pre>';
function display_crashes_vs_app_versions_pie_chart($issue_id) { $columns = array(); $columns[] = "count(*) as nb_crashes"; $columns[] = "app_version_code"; $selection = array(); $selectionArgs = array(); // Filter by issue ID $selection[] = "issue_id = ?"; $selectionArgs[] = $issue_id; // Filter by last 30 days only $selection[] = "added_date > ?"; $selectionArgs[] = time() - 30 * 86400; $groupBy = "app_version_code"; $orderBy = null; $sql = bicou_mysql_select($columns, "crashes", implode(" AND ", $selection), $selectionArgs, $orderBy, $groupBy); $res = mysql_query($sql); echo <<<HTML <div id="crashes_vs_app_versions" style="margin-left: 550px; height:300px; width:500px;"></div> <script>\$(document).ready(function(){ var data = []; HTML; $plots = array(); while ($tab = mysql_fetch_array($res)) { echo " data.push(['V" . $tab[app_version_code] . "', " . $tab[nb_crashes] . "]);\n"; } echo <<<HTML var crashes_vs_app_versions = jQuery.jqplot('crashes_vs_app_versions', [data], { title: 'Crashes vs. App Versions', seriesDefaults: { renderer: jQuery.jqplot.PieRenderer, rendererOptions: { dataLabelFormatString: '%.1f%%', showDataLabels: true } }, legend: { show:true, location: 'e', rendererOptions: { numberColumns: 3 }, } } ); });</script> HTML; }