Skip to content

Commit 6b0332e

Browse files
committed
added sorting to timers
1 parent 4ac5aac commit 6b0332e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

handlers/Main.cfc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,41 @@ component extends="coldbox.system.RestHandler" {
9595
* Get the profilers via ajax
9696
*/
9797
function renderProfilers( event, rc, prc ){
98+
// Sorting: timestamp, executionTime
99+
event.paramValue( "sortBy", "timestamp" )
100+
.paramValue( "sortOrder", "desc" );
101+
102+
// Get the profilers
103+
var aProfilers = variables.debuggerService.getProfilerStorage();
104+
105+
// Sorting?
106+
switch( rc.sortBy ){
107+
case "executionTime" : {
108+
arraySort( aProfilers, function( e1, e2 ){
109+
if( rc.sortOrder == "asc" ){
110+
return ( arguments.e1.executionTime < arguments.e2.executionTime ? -1 : 1 );
111+
}
112+
return ( arguments.e1.executionTime > arguments.e2.executionTime ? -1 : 1 );
113+
} );
114+
break;
115+
}
116+
default: {
117+
arraySort( aProfilers, function( e1, e2 ){
118+
if( rc.sortOrder == "asc" ){
119+
return dateCompare( arguments.e1.timestamp, arguments.e2.timestamp );
120+
}
121+
return dateCompare( arguments.e2.timestamp, arguments.e1.timestamp );
122+
} );
123+
break;
124+
}
125+
}
126+
98127
return renderView(
99128
view : "main/partials/profilers",
100129
module: "cbdebugger",
101130
args : {
102131
environment : variables.debuggerService.getEnvironment(),
103-
profilers : variables.debuggerService.getProfilerStorage(),
132+
profilers : aProfilers,
104133
debuggerConfig : variables.debuggerConfig
105134
},
106135
prePostExempt: true

0 commit comments

Comments
 (0)