Permalink
Browse files

SQL: a bit of query plan love

This updates to the latest from https://github.com/JustinPealing/html-query-plan and makes dark themes a bit more readable. This also finishes prettyprint -> highlightjs
  • Loading branch information...
Nick Craver
Nick Craver committed Oct 9, 2018
1 parent 1462965 commit 1aaf4a08cb26ec2537ed5ff37e8b2c0c0aa7bd6b
@@ -45,6 +45,7 @@ public bool IsMinor
private static readonly Regex initParamsTrimRegex = new Regex(@"^\s*(begin|end)\s*", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex paramRegex = new Regex(@"^\(( [^\(\)]* ( ( (?<Open>\() [^\(\)]* )+ ( (?<Close-Open>\)) [^\(\)]* )+ )* (?(Open)(?!)) )\)", RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
private static readonly Regex paramSplitRegex = new Regex(@",(?=[@])", RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
private static readonly char[] startTrimChars = new[] { '\n', '\r', ';' };
public string ParameterDeclareStatement
{
@@ -60,7 +61,7 @@ public string StatementTextWithoutInitialParams
get
{
//TODO: Pair these down, seeing what looks good for now
return this is StmtSimpleType ss ? emptyLineRegex.Replace(paramRegex.Replace(ss.StatementText ?? "", ""), "").Trim() : "";
return this is StmtSimpleType ss ? emptyLineRegex.Replace(paramRegex.Replace(ss.StatementText ?? "", ""), "").Trim().TrimStart(startTrimChars) : "";
}
}
View
Binary file not shown.
@@ -245,6 +245,12 @@
});
}
function highlight() {
$('pre code').each(function (i, block) {
hljs.highlightBlock(block);
});
}
function init(options) {
Status.options = options;
@@ -392,7 +398,6 @@
}
});
prepTableSorter();
prettyPrint();
hljs.initHighlighting();
}
@@ -403,6 +408,7 @@
list: loadersList,
register: registerLoaders
},
highlight: highlight,
graphCount: 0,
refresh: {
register: registerRefresh,
@@ -714,21 +720,20 @@ Status.SQL = (function () {
}, {
onLoad: function() {
$(this).closest('.modal-lg').removeClass('modal-lg').addClass('modal-huge');
prettyPrint();
Status.highlight();
if ($('.qp-root').length) {
$('.qp-root').drawQueryPlanLines();
var currentTt;
$(this).find('.qp-node').hover(function () {
var pos = $(this).offset();
var tt = $(this).find('.qp-tt');
currentTt = tt.clone();
currentTt.addClass('sql-query-tooltip')
.appendTo(document.body)
.css({ top: pos.top + $(this).outerHeight(), left: pos.left })
.show();
}, function () {
if (currentTt) currentTt.hide();
});
//var currentTt;
//$(this).find('.qp-node').hover(function () {
// var pos = $(this).offset();
// var tt = $(this).find('.qp-tt');
// currentTt = tt.clone();
// currentTt.addClass('sql-query-tooltip')
// .appendTo(document.body)
// .css({ top: pos.top + $(this).outerHeight(), left: pos.left })
// .show();
//}, function () {
// if (currentTt) currentTt.hide();
//});
}
$(this).find('.js-remove-plan').on('click', function() {
if ($(this).hasClass('js-confirm')) {

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 1aaf4a0

Please sign in to comment.