diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c091839 --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Numerous always-ignore extensions +################### +*.diff +*.err +*.orig +*.log +*.rej +*.swo +*.swp +*.vi +*~ + +*.sass-cache +# Folders to ignore +################### +.hg +.svn +.CVS +# OS or Editor folders +################### +.DS_Store +Icon? +Thumbs.db +ehthumbs.db +nbproject +.cache +.project +.settings +.tmproj +*.esproj +*.sublime-project +*.sublime-workspace +# Dreamweaver added files +################### +_notes +dwsync.xml +# Komodo +################### +*.komodoproject +.komodotools diff --git a/README.markdown b/README.markdown index 5611242..571d995 100644 --- a/README.markdown +++ b/README.markdown @@ -2,9 +2,9 @@ This is a simple UI to put on top of the data that mk-query-digest outputs. It let's you browse the query report in a more readable fashion. The aim is to display all the information from the report in a readable, navigable way. -This tool does not add anything to the `mk-query-digest` utility itself. It simply displays the data that the utility generates. +This tool does not add anything to the `mk-query-digest` utility itself. It simply displays the data that the utility generates. -The name comes from the tool's purpose - "hunting whale queries" - and Richard Crowley's free-associating mind. +The name comes from the tool's purpose - "hunting whale queries" - and Richard Crowley's free-associating mind. ## Usage diff --git a/dashboard.php b/dashboard.php index 261a62d..5257627 100644 --- a/dashboard.php +++ b/dashboard.php @@ -32,10 +32,10 @@ # Get total amount of query time (for % later) $q = "SELECT - SUM(query_time_sum) - FROM + SUM(query_time_sum) + FROM {$host_conf['db_query_review_history_table']} - WHERE + WHERE ts_max > date_sub(now(),interval {$hours} hour);"; $result = mysql_query($q); $query_time_sum = mysql_result($result, 0); @@ -45,10 +45,10 @@ # Get total # of queries in history window (for % later) $q = "SELECT - SUM(ts_cnt) - FROM + SUM(ts_cnt) + FROM {$host_conf['db_query_review_history_table']} - WHERE + WHERE ts_max > date_sub(now(),interval $hours hour);"; $result = mysql_query($q); $query_qty_sum = mysql_result($result, 0); @@ -67,10 +67,10 @@ (SUM(ts_cnt)/{$query_qty_sum}*100) AS qty_pct, (SUM(query_time_sum)/{$query_time_sum}*100) AS time_pct, ((SUM(query_time_sum)/{$query_time_sum}*100)/(SUM(ts_cnt)/{$query_qty_sum}*100)) AS ratio - FROM + FROM {$host_conf['db_query_review_history_table']} - WHERE - ts_max > date_sub(now(),interval $hours hour) + WHERE + ts_max > date_sub(now(),interval $hours hour) GROUP BY checksum ORDER BY $sort DESC LIMIT 20"; $result = mysql_query($q); diff --git a/explain.php b/explain.php index 8f60e93..29a4e96 100644 --- a/explain.php +++ b/explain.php @@ -13,7 +13,7 @@ $row = mysql_fetch_assoc($result); $query = $row['sample']; $explain = "EXPLAIN ".preg_replace('|^\s*\/\*.*\*\/|', '', $query); - + mysql_select_db($host_conf['db_database_live']) or die("Unable to select database"); $is_select_query = (stripos($explain, 'SELECT') !== false); diff --git a/init.php b/init.php index b339e15..18174f2 100644 --- a/init.php +++ b/init.php @@ -66,7 +66,7 @@ function ish_get_host_config($host) { return $host_config; } - # build up a query string using 1. things we need in every URL and + # build up a query string using 1. things we need in every URL and # 2. whatever is passed in $args as k-v pairs function ish_build_query($args) { global $host; diff --git a/media/BitmapType.js b/media/BitmapType.js index d91845c..46ec497 100644 --- a/media/BitmapType.js +++ b/media/BitmapType.js @@ -1,7 +1,7 @@ var BitmapType = function() { - + return { - + // Insert a canvas element in place of text. convert: function(el, attr) { @@ -25,31 +25,31 @@ var BitmapType = function() { for(var index = 0, position = 0, rows = 1, tLen = tokens.length; index < tLen; index++) { var token = tokens[index], glyph = font[token]; - + for(var n = index, len = tokens.length; n < len; n++) { if(tokens[n] === 'space') break; } var nextSpace = n; var wordWidth = BitmapType.calculateLength(tokens.slice(index, nextSpace), font, scale).totalWidth; var letterWidth = BitmapType.calculateLength(tokens.slice(index, index + 1), font, scale).totalWidth; - + if((position + wordWidth > width) && ((tokens[index - 1] === 'space' && wordWidth <= width) || (position + letterWidth > width))) { rows++; position = 0; } - position += (glyph[0].length + 1) * scale; + position += (glyph[0].length + 1) * scale; } height = length.lineHeight * rows; var angle = attr.angle || 0; var canvasWidth = (angle === 90 || angle === 270) ? height : width; var canvasHeight = (angle === 90 || angle === 270) ? width : height; - + if(YAHOO.env.ua.webkit >= 412 && YAHOO.env.ua.webkit < 522) { // Safari 2 canvas.style.width = canvasWidth + 'px'; canvas.style.height = canvasHeight + 'px'; } - else { + else { canvas.width = canvasWidth; canvas.height = canvasHeight; } @@ -59,9 +59,9 @@ var BitmapType = function() { canvas = YAHOO.util.Dom.get(el.id + '-bitmap-type-canvas'); // Get a new reference to the canvas. } var ctx = canvas.getContext('2d'); - + // Get the current color of the text. - + var color = '#000'; // Default color. if(el.currentStyle) { // IE color = el.currentStyle['color']; @@ -79,9 +79,9 @@ var BitmapType = function() { row = position[1]; } }, - + // Draw text on a canvas element. - + addStringToCanvas: function(text, ctx, attr) { var x = attr.x || 0; var y = attr.y || 0; @@ -91,7 +91,7 @@ var BitmapType = function() { var angle = attr.angle || 0; var color = attr.color || '#000'; var textAlign = attr.textAlign || 'left'; - + var tokens = BitmapType.tokenize(text); var length = BitmapType.calculateLength(tokens, font, scale, lineSpacing); @@ -101,19 +101,19 @@ var BitmapType = function() { for(var index = 0, position = 0, rows = 1, tLen = tokens.length; index < tLen; index++) { var token = tokens[index], glyph = font[token]; - + for(var n = index, len = tokens.length; n < len; n++) { if(tokens[n] === 'space') break; } var nextSpace = n; var wordWidth = BitmapType.calculateLength(tokens.slice(index, nextSpace), font, scale).totalWidth; var letterWidth = BitmapType.calculateLength(tokens.slice(index, index + 1), font, scale).totalWidth; - + if((position + wordWidth > width) && ((tokens[index - 1] === 'space' && wordWidth <= width) || (position + letterWidth > width))) { rows++; position = 0; } - position += (glyph[0].length + 1) * scale; + position += (glyph[0].length + 1) * scale; } height = length.lineHeight * rows; ctx.fillStyle = color; @@ -128,9 +128,9 @@ var BitmapType = function() { row = position[1]; } }, - + // Helper methods. - + tokenize: function(text) { if(text === null || text === undefined) text = ''; text = text.toString().replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&'); @@ -165,13 +165,13 @@ var BitmapType = function() { case ',': token = 'comma'; break; case '.': token = 'period'; break; case '/': token = 'rightSlash'; break; case '<': token = 'leftAngleBracket'; break; case '>': token = 'rightAngleBracket'; break; case '?': token = 'questionMark'; break; - default: token = ''; + default: token = ''; } if(token !== '') tokens.push(token); - } + } return tokens; }, - + calculateLength: function(tokens, font, scale, lineSpacing) { var length = { totalWidth: 0 }; for(var n = 0, len = tokens.length; n < len; n++) { @@ -181,21 +181,21 @@ var BitmapType = function() { length.lineHeight = (font['space'].length + lineSpacing) * scale; return length; }, - + translate: function(tokens, index, position, row, width, height, ctx, font, angle, scale, length, x, y) { if(x === undefined) x = 0; - if(y === undefined) y = 0; + if(y === undefined) y = 0; var token = tokens[index], glyph = font[token]; - + for(var n = index, len = tokens.length; n < len; n++) { if(tokens[n] === 'space') break; } var nextSpace = n; var wordWidth = BitmapType.calculateLength(tokens.slice(index, nextSpace), font, scale).totalWidth; var letterWidth = BitmapType.calculateLength(tokens.slice(index, index + 1), font, scale).totalWidth; - + if((position + wordWidth > width) && ((tokens[index - 1] === 'space' && wordWidth <= width) || (position + letterWidth > width))) { row++; position = 0; @@ -206,7 +206,7 @@ var BitmapType = function() { switch(angle) { case 90: ctx.fillRect(len - n + x, m + position + y, scale, scale); break; case 180: ctx.fillRect(length - (m + position) - 1 + x, len - n + y, scale, scale); break; - case 270: ctx.fillRect(n + x, length - (m + position) - 1 + y, scale, scale); break; + case 270: ctx.fillRect(n + x, length - (m + position) - 1 + y, scale, scale); break; default: ctx.fillRect(m + position + x, n + (row * height) + y, scale, scale); break; } } diff --git a/media/Fonts.js b/media/Fonts.js index 487a4bb..2f6ee34 100644 --- a/media/Fonts.js +++ b/media/Fonts.js @@ -66,7 +66,7 @@ var Fonts = { eight: [[0,0,0,0],[0,1,1,0],[1,0,0,1],[0,1,1,0],[1,0,0,1],[0,1,1,0],[0,0,0,0]], nine: [[0,0,0,0],[0,1,1,0],[1,0,0,1],[0,1,1,1],[0,0,0,1],[0,1,1,0],[0,0,0,0]], zero: [[0,0,0,0],[0,1,1,0],[1,0,0,1],[1,0,0,1],[1,0,0,1],[0,1,1,0],[0,0,0,0]], - + exclaimationPoint: [[0],[1],[1],[1],[0],[1],[0]], at: [[0,0,0,0,0],[0,1,1,1,0],[1,0,1,0,1],[1,0,1,1,0],[1,0,0,0,0],[0,1,1,1,0],[0,0,0,0,0]], hash: [[0,0,0,0,0],[0,1,0,1,0],[1,1,1,1,1],[0,1,0,1,0],[1,1,1,1,1],[0,1,0,1,0],[0,0,0,0,0]], @@ -167,7 +167,7 @@ var Fonts = { eight: [[0,0,0,0,0],[0,0,0,0,0],[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,0],[0,0,0,0,0],[0,0,0,0,0]], nine: [[0,0,0,0,0],[0,0,0,0,0],[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[0,1,1,1,1],[0,0,0,0,1],[0,1,1,1,0],[0,0,0,0,0],[0,0,0,0,0]], zero: [[0,0,0,0,0],[0,0,0,0,0],[0,1,1,1,0],[1,0,0,0,1],[1,0,0,1,1],[1,0,1,0,1],[1,1,0,0,1],[1,0,0,0,1],[0,1,1,1,0],[0,0,0,0,0],[0,0,0,0,0]], - + exclaimationPoint: [[0,0,0,0,0],[0,0,0,0,0],[0,0,1,0,0],[0,0,1,0,0],[0,0,1,0,0],[0,0,1,0,0],[0,0,1,0,0],[0,0,0,0,0],[0,0,1,0,0],[0,0,0,0,0],[0,0,0,0,0]], at: [[0,0,0,0,0],[0,1,1,1,0],[1,0,0,0,1],[1,0,0,0,1],[1,0,1,0,1],[1,1,1,0,1],[1,0,1,1,0],[1,0,0,0,0],[1,0,0,0,1],[0,1,1,1,0],[0,0,0,0,0]], hash: [[0,0,0,0,0],[0,0,0,0,0],[0,1,0,1,0],[1,1,1,1,1],[0,1,0,1,0],[1,1,1,1,1],[0,1,0,1,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]], diff --git a/media/graph.js b/media/graph.js index eae211a..9df980b 100644 --- a/media/graph.js +++ b/media/graph.js @@ -1,7 +1,7 @@ - - - - + + + + /* Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: @@ -29,14 +29,14 @@ var Fonts={Silkscreen:{a:[[0,0,0,0],[0,1,1,0],[1,0,0,1],[1,1,1,1],[1,0,0,1],[1,0 var TF = window.TF || {}; -TF.Graph = function(elementId, attr, seriesInfo, dataSource) { +TF.Graph = function(elementId, attr, seriesInfo, dataSource) { // Call the superclass' constructor. - TF.Graph.superclass.constructor.call(this, elementId, attr, seriesInfo, dataSource); + TF.Graph.superclass.constructor.call(this, elementId, attr, seriesInfo, dataSource); }; YAHOO.lang.extend(TF.Graph, YAHOO.Smb.Graph); TF.Graph.prototype.drawBar = function(dataSet, color) { - + // Draw the colored background. var barWidth = this.scale.horiz; @@ -44,10 +44,10 @@ TF.Graph.prototype.drawBar = function(dataSet, color) { for(var n = this.start, len = dataSet.length; n < this.end && n < len; n++) { var barHeight = this.height - ((dataSet[n].y.value - this.min) * this.scale.vert) - this.paddingBottom; - this.ctx.fillStyle = dataSet[n].color; + this.ctx.fillStyle = dataSet[n].color; this.ctx.fillRect(dataSet[n].x.value * horizConstant + this.paddingLeft, barHeight, barWidth, dataSet[n].y.value * this.scale.vert); - } - + } + return this; }; @@ -77,16 +77,16 @@ TF.Graph.prototype.drawLabels = function() { if(y < 0) continue; this.typeLib.addStringToCanvas(label, this.ctx, { x: x, y: y, font: this.labelFont, color: this.barLabelColor, scale: this.labelFontScale, angle: 270 }); - } + } } - } + } return this; }; TF.Graph.prototype.addDataSet = function(data, layout) { var xLabel = layout.xLabel || layout.x; - var yLabel = layout.yLabel || layout.y; + var yLabel = layout.yLabel || layout.y; var color = layout.color || '#cc0000'; if(this.type === 'pie') { @@ -124,9 +124,9 @@ TF.Graph.prototype.addDataSet = function(data, layout) { TF.Graph.prototype.updateHoverInfo = function(e) { if(isNaN(this.canvasPosition.x) || isNaN(this.canvasPosition.y)) { - this.canvasPosition = { - x: YAHOO.util.Dom.getX(this.canvas) - this.parentPosition.x, - y: YAHOO.util.Dom.getY(this.canvas) - this.parentPosition.y + this.canvasPosition = { + x: YAHOO.util.Dom.getX(this.canvas) - this.parentPosition.x, + y: YAHOO.util.Dom.getY(this.canvas) - this.parentPosition.y }; } var x = Math.round((e.clientX - this.canvasPosition.x - this.parentPosition.x - this.paddingLeft) / this.scale.horiz) + this.start; @@ -136,7 +136,7 @@ TF.Graph.prototype.updateHoverInfo = function(e) { } // Fire the custom event. - + var inGraph = false; var args = []; if(x >= this.start) { diff --git a/more.php b/more.php index 46bc280..3a075b7 100644 --- a/more.php +++ b/more.php @@ -18,13 +18,13 @@ 'sum', 'min', 'max', 'pct_95', 'stddev', 'median', ); - $q = "SELECT + $q = "SELECT * FROM {$host_conf['db_query_review_history_table']} WHERE checksum={$checksum} AND - ts_max > date_sub(now(),interval $hours hour) + ts_max > date_sub(now(),interval $hours hour) ORDER BY ts_max ASC"; $result=mysql_query($q); diff --git a/table.php b/table.php index 43b83c4..465aec8 100644 --- a/table.php +++ b/table.php @@ -14,12 +14,12 @@ {$host_conf['db_query_review_table']} as t join {$host_conf['db_query_review_history_table']} as h - on - t.checksum=h.checksum - where + on + t.checksum=h.checksum + where t.sample like '% {$table} %' AND - h.ts_max > date_sub(now(),interval {$hours} hour) + h.ts_max > date_sub(now(),interval {$hours} hour) group by t.checksum order by count desc"; $result=mysql_query($q);