Skip to content

Instantly share code, notes, and snippets.

@crccheck
Created November 9, 2010 01:09
Show Gist options
  • Save crccheck/668559 to your computer and use it in GitHub Desktop.
Save crccheck/668559 to your computer and use it in GitHub Desktop.
Sort Django Debug Toolbar SQL by execution time
jQuery.fn.sort = function() { return this.pushStack( [].sort.apply( this, arguments ), []); };
$('.djDebugSql').closest('tr').each(function(i) { this.setAttribute('rel',i); });
function dtsql(o){
switch (o) {
case 'clean' : $('.djDebugSql').each(function(){ $(this).contents()[1].nodeValue = ' '; }); break;
case 'time' : tbody = $('.djDebugSql:eq(0)').closest('tbody'); tbody.children('tr').sort(function(a,b){ return $(b).children('td:eq(0)').html() - $(a).children('td:eq(0)').html() }).appendTo(tbody);
break;
}
}
dtsql('time');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment