Skip to content

Commit 34efc04

Browse files
committed
* New Slowest Queries panel for cborm, acf, and qb/quick
1 parent 046b252 commit 34efc04

File tree

7 files changed

+460
-308
lines changed

7 files changed

+460
-308
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
* Ability to open the Handler events that are profiled by the Request Collector in any Code Editor.
1919
* New life-cycle events: onDebuggerUnload, onDebuggerLoad
2020
* Ability for the custom `timeIt()` functions to accept metdata to store in the execution timer
21+
* New `Slowest` Queries panel for cborm, acf, and qb/quick
2122

2223
### Fixed
2324

views/main/panels/requestTracker/acfSqlPanel.cfm

Lines changed: 47 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
},
2020
isTimelineView(){
2121
return this.queryView == 'timeline'
22+
},
23+
isSlowestView(){
24+
return this.queryView == 'slowest'
2225
}
2326
}"
2427
>
@@ -77,6 +80,7 @@
7780

7881
<!--- ToolBar --->
7982
<div class="p10">
83+
<!--- Grouped --->
8084
<button
8185
:class="{ 'cbd-selected' : isGroupView() }"
8286
@click="queryView='grouped'"
@@ -86,6 +90,7 @@
8690
</svg>
8791
Grouped
8892
</button>
93+
<!--- Timeline --->
8994
<button
9095
:class="{ 'cbd-selected' : isTimelineView() }"
9196
@click="queryView='timeline'"
@@ -95,6 +100,14 @@
95100
</svg>
96101
Timeline
97102
</button>
103+
<!--- Slowest --->
104+
<button
105+
:class="{ 'cbd-selected' : isSlowestView() }"
106+
@click="queryView='slowest'"
107+
>
108+
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
109+
Slowest
110+
</button>
98111
</div>
99112

100113
<!--- Query Views --->
@@ -237,115 +250,41 @@
237250
x-show="isTimelineView"
238251
x-transition
239252
>
240-
<table
241-
border="0"
242-
align="center"
243-
cellpadding="0"
244-
cellspacing="1"
245-
class="cbd-tables">
246-
<thead>
247-
<tr>
248-
<th width="125" align="center">Timestamp</th>
249-
<th width="100" align="center">Execution Time</th>
250-
<th width="100" align="center">Datasource</th>
251-
<th>Query</th>
252-
</tr>
253-
</thead>
254-
<tbody>
255-
<cfloop query="#args.profiler.cfQueries.all#">
256-
<cfset q = args.profiler.cfQueries.all>
257-
<cfif q.type neq "SqlQuery">
258-
<cfcontinue>
259-
</cfif>
260-
<cfset rowId = createUUID()>
261-
<tr>
262-
<td align="center">
263-
#TimeFormat( q.timestamp,"hh:MM:SS.l tt" )#
264-
</td>
265-
266-
<td align="center">
267-
#numberFormat( ( q.endTime - q.startTime ) )# ms
268-
</td>
269-
270-
<td align="center">
271-
#q.datasource#
272-
</td>
273-
274-
<td>
275-
<cfif q.template.len()>
276-
<div class="mb10 mt10 cbd-params">
277-
<!--- Title --->
278-
<strong>Called From: </strong>
279-
<!--- Open in Editor--->
280-
<cfif args.debuggerService.openInEditorURL( event, q.stackTrace[ 1 ][ 1 ] ) NEQ "">
281-
<div class="cbd-floatRight">
282-
<a
283-
class="cbd-button"
284-
target="_self"
285-
rel ="noreferrer noopener"
286-
title="Open in Editor"
287-
href="#args.debuggerService.openInEditorURL( event, q.stackTrace[ 1 ][ 1 ] )#"
288-
>
289-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
290-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
291-
</svg>
292-
</a>
293-
</div>
294-
</cfif>
295-
<!--- Line --->
296-
<div>
297-
<strong>
298-
#replaceNoCase( q.template, appPath, "" )#:#q.line#
299-
</strong>
300-
</div>
301-
</div>
302-
</cfif>
303-
304-
<!--- Sql Code --->
305-
<code id="acfSql-timelinesql-#rowId#">
306-
<svg
307-
xmlns="http://www.w3.org/2000/svg"
308-
class="h-6 w-6 cbd-floatRight cbd-text-pre mt5"
309-
fill="none"
310-
viewBox="0 0 24 24"
311-
stroke="currentColor"
312-
title="Copy SQL to Clipboard"
313-
style="width: 50px; height: 50px; cursor: pointer;"
314-
onclick="coldboxDebugger.copyToClipboard( 'acfSql-timelinesql-#rowId#' )"
315-
>
316-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
317-
</svg>
318-
<pre>#sqlFormatter.format( q.body )#</pre>
319-
</code>
253+
#renderView(
254+
view : "main/panels/requestTracker/acfSqlTable",
255+
module : "cbdebugger",
256+
args : {
257+
sqlData : args.profiler.cfQueries.all,
258+
debuggerService : args.debuggerService,
259+
sqlFormatter : sqlFormatter,
260+
jsonFormatter : jsonFormatter,
261+
appPath : appPath
262+
},
263+
prePostExempt : true
264+
)#
265+
</div>
320266

321-
<!--- Params --->
322-
<cfif NOT q.attributes.isEmpty()>
323-
<div class="mt10 mb5 cbd-params">
324-
<div class="mb10">
325-
<strong>Params: </strong>
326-
</div>
327-
<code id="acfSql-timelinesql-params-#rowId#">
328-
<svg
329-
xmlns="http://www.w3.org/2000/svg"
330-
class="h-6 w-6 cbd-floatRight cbd-text-pre mt5"
331-
fill="none"
332-
viewBox="0 0 24 24"
333-
stroke="currentColor"
334-
title="Copy SQL to Clipboard"
335-
style="width: 50px; height: 50px; cursor: pointer;"
336-
onclick="coldboxDebugger.copyToClipboard( 'acfSql-timelinesql-params-#rowId#' )"
337-
>
338-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
339-
</svg>
340-
<pre>#jsonFormatter.formatJSON( json : q.attributes, spaceAfterColon : true )#</pre>
341-
</code>
342-
</div>
343-
</cfif>
344-
</td>
345-
</tr>
346-
</cfloop>
347-
</tbody>
348-
</table>
267+
<!--- Slowest Queries --->
268+
<div
269+
x-show="isSlowestView"
270+
x-transition
271+
>
272+
#renderView(
273+
view : "main/panels/requestTracker/acfSqlTable",
274+
module : "cbdebugger",
275+
args : {
276+
sqlData : args.profiler.cfQueries.all.sort( function( a, b ){
277+
var executionTimeA = a.endTime - a.startTime;
278+
var executionTimeB = b.endTime - b.startTime;
279+
return executionTimeA < executionTimeB ? 1 : -1;
280+
} ),
281+
debuggerService : args.debuggerService,
282+
sqlFormatter : sqlFormatter,
283+
jsonFormatter : jsonFormatter,
284+
appPath : appPath
285+
},
286+
prePostExempt : true
287+
)#
349288
</div>
350289
</cfif>
351290
</div>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<cfoutput>
2+
<table
3+
border="0"
4+
align="center"
5+
cellpadding="0"
6+
cellspacing="1"
7+
class="cbd-tables"
8+
>
9+
<thead>
10+
<tr>
11+
<th width="125" align="center">Timestamp</th>
12+
<th width="100" align="center">Execution Time</th>
13+
<th width="100" align="center">Datasource</th>
14+
<th>Query</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
<cfloop query="#args.sqlData#">
19+
<cfset q = args.sqlData>
20+
<cfif q.type neq "SqlQuery">
21+
<cfcontinue>
22+
</cfif>
23+
<cfset rowId = createUUID()>
24+
<tr>
25+
<td align="center">
26+
#TimeFormat( q.timestamp,"hh:MM:SS.l tt" )#
27+
</td>
28+
29+
<td align="center">
30+
#numberFormat( ( q.endTime - q.startTime ) )# ms
31+
</td>
32+
33+
<td align="center">
34+
#q.datasource#
35+
</td>
36+
37+
<td>
38+
<cfif q.template.len()>
39+
<div class="mb10 mt10 cbd-params">
40+
<!--- Title --->
41+
<strong>Called From: </strong>
42+
<!--- Open in Editor--->
43+
<cfif args.debuggerService.openInEditorURL( event, q.stackTrace[ 1 ][ 1 ] ) NEQ "">
44+
<div class="cbd-floatRight">
45+
<a
46+
class="cbd-button"
47+
target="_self"
48+
rel ="noreferrer noopener"
49+
title="Open in Editor"
50+
href="#args.debuggerService.openInEditorURL( event, q.stackTrace[ 1 ][ 1 ] )#"
51+
>
52+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
53+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
54+
</svg>
55+
</a>
56+
</div>
57+
</cfif>
58+
<!--- Line --->
59+
<div>
60+
<strong>
61+
#replaceNoCase( q.template, args.appPath, "" )#:#q.line#
62+
</strong>
63+
</div>
64+
</div>
65+
</cfif>
66+
67+
<!--- Sql Code --->
68+
<code id="acfSql-timelinesql-#rowId#">
69+
<svg
70+
xmlns="http://www.w3.org/2000/svg"
71+
class="h-6 w-6 cbd-floatRight cbd-text-pre mt5"
72+
fill="none"
73+
viewBox="0 0 24 24"
74+
stroke="currentColor"
75+
title="Copy SQL to Clipboard"
76+
style="width: 50px; height: 50px; cursor: pointer;"
77+
onclick="coldboxDebugger.copyToClipboard( 'acfSql-timelinesql-#rowId#' )"
78+
>
79+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
80+
</svg>
81+
<pre>#args.sqlFormatter.format( q.body )#</pre>
82+
</code>
83+
84+
<!--- Params --->
85+
<cfif NOT q.attributes.isEmpty()>
86+
<div class="mt10 mb5 cbd-params">
87+
<div class="mb10">
88+
<strong>Params: </strong>
89+
</div>
90+
<code id="acfSql-timelinesql-params-#rowId#">
91+
<svg
92+
xmlns="http://www.w3.org/2000/svg"
93+
class="h-6 w-6 cbd-floatRight cbd-text-pre mt5"
94+
fill="none"
95+
viewBox="0 0 24 24"
96+
stroke="currentColor"
97+
title="Copy SQL to Clipboard"
98+
style="width: 50px; height: 50px; cursor: pointer;"
99+
onclick="coldboxDebugger.copyToClipboard( 'acfSql-timelinesql-params-#rowId#' )"
100+
>
101+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
102+
</svg>
103+
<pre>#args.jsonFormatter.formatJSON( json : q.attributes, spaceAfterColon : true )#</pre>
104+
</code>
105+
</div>
106+
</cfif>
107+
</td>
108+
</tr>
109+
</cfloop>
110+
</tbody>
111+
</table>
112+
</cfoutput>

0 commit comments

Comments
 (0)