adonisjs-server-stats 1.11.7 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/core/explain-utils.d.ts +77 -0
  2. package/dist/core/index.d.ts +8 -2
  3. package/dist/core/index.js +1089 -877
  4. package/dist/core/queries-columns.d.ts +42 -0
  5. package/dist/core/queries-controller.d.ts +94 -0
  6. package/dist/core/query-utils.d.ts +49 -0
  7. package/dist/react/{CacheSection-DOUnyUrw.js → CacheSection-DZFOiOYH.js} +1 -1
  8. package/dist/react/{CacheTab-D9o6bsPc.js → CacheTab-D8js5o69.js} +1 -1
  9. package/dist/react/{ConfigSection-DzNC7pOJ.js → ConfigSection-DoJmvNkF.js} +1 -1
  10. package/dist/react/{ConfigTab-CT-Tu-ct.js → ConfigTab-CDvljuBF.js} +1 -1
  11. package/dist/react/{CustomPaneTab-CvIPe7NP.js → CustomPaneTab-Db9eIQ-9.js} +1 -1
  12. package/dist/react/{EmailsSection-B1LT7Nx3.js → EmailsSection-D7oxvAjA.js} +1 -1
  13. package/dist/react/{EmailsTab-DKxK322z.js → EmailsTab-BITuGTQm.js} +1 -1
  14. package/dist/react/{EventsSection-D3AK0mhw.js → EventsSection-7mDZv70I.js} +1 -1
  15. package/dist/react/{EventsTab-BRRSW6RI.js → EventsTab-DF13BChE.js} +1 -1
  16. package/dist/react/{JobsSection-BMvj5886.js → JobsSection-B_VJFWy6.js} +1 -1
  17. package/dist/react/{JobsTab-CQXWCrl8.js → JobsTab-DK8Fl9nz.js} +1 -1
  18. package/dist/react/{LogEntryRow-DFI52ZEw.js → LogEntryRow-Bdie9SFe.js} +1 -1
  19. package/dist/react/{LogsSection-CW2hQ976.js → LogsSection-CrWqxWRr.js} +2 -2
  20. package/dist/react/{LogsTab-CV4Gf_yb.js → LogsTab-DYSpL637.js} +2 -2
  21. package/dist/react/{OverviewSection-CxF9cabq.js → OverviewSection-CuaccMZt.js} +1 -1
  22. package/dist/react/QueriesContent-BDIx8zFn.js +288 -0
  23. package/dist/react/QueriesSection-CvGGh5Ij.js +117 -0
  24. package/dist/react/QueriesTab-C7CCwhVc.js +87 -0
  25. package/dist/react/{RequestsSection-Cb5YeqvI.js → RequestsSection-mENyeNsk.js} +2 -2
  26. package/dist/react/{RoutesSection-B43olD9v.js → RoutesSection-DjovlaNS.js} +1 -1
  27. package/dist/react/{RoutesTab-RfhCUbkx.js → RoutesTab-CbQECiUc.js} +1 -1
  28. package/dist/react/{SplitPaneWrapper-B05Mg6Sg.js → SplitPaneWrapper-DyRyH5Re.js} +1 -1
  29. package/dist/react/{TimelineTab-Dx4686Ti.js → TimelineTab-BKTFbsPe.js} +2 -2
  30. package/dist/react/components/shared/QueriesContent.d.ts +33 -0
  31. package/dist/react/{index-C4EMJrkH.js → index-CAUHa8QX.js} +2 -2
  32. package/dist/react/index.js +1 -1
  33. package/dist/react/style.css +1 -1
  34. package/dist/src/dashboard/query_explain_handler.d.ts +11 -0
  35. package/dist/src/dashboard/query_explain_handler.js +64 -11
  36. package/dist/src/debug/query_collector.d.ts +1 -0
  37. package/dist/src/debug/query_collector.js +3 -0
  38. package/dist/src/edge/client/dashboard.js +2 -2
  39. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  40. package/dist/src/edge/client-vue/dashboard.js +4 -4
  41. package/dist/src/edge/client-vue/debug-panel-deferred.js +2 -2
  42. package/dist/src/provider/server_stats_provider.js +2 -0
  43. package/dist/src/routes/debug_routes.d.ts +4 -0
  44. package/dist/src/routes/debug_routes.js +45 -0
  45. package/dist/src/routes/register_routes.d.ts +4 -0
  46. package/dist/src/routes/register_routes.js +2 -0
  47. package/dist/src/styles/components.css +238 -0
  48. package/dist/src/styles/dashboard.css +6 -173
  49. package/dist/src/styles/debug-panel.css +2 -24
  50. package/dist/vue/{CacheSection-BAotiuQq.js → CacheSection-Bx41lpfK.js} +1 -1
  51. package/dist/vue/{ConfigSection-JZjK5E5F.js → ConfigSection-fkfUdCmx.js} +1 -1
  52. package/dist/vue/{EmailsSection-BLwyQO7B.js → EmailsSection-CbcDKF9Q.js} +1 -1
  53. package/dist/vue/{EventsSection-BUEwO-0A.js → EventsSection-CWbTYOBi.js} +1 -1
  54. package/dist/vue/{JobsSection-21A0yQMq.js → JobsSection-CGGO6rtS.js} +1 -1
  55. package/dist/vue/{LogsSection-BmOx8SNa.js → LogsSection-BPB-C-XA.js} +1 -1
  56. package/dist/vue/{OverviewSection-BRDK3Ony.js → OverviewSection-BTcnPeoM.js} +1 -1
  57. package/dist/vue/QueriesSection-2SE3igQJ.js +411 -0
  58. package/dist/vue/QueriesTab-DO5XwJ--.js +112 -0
  59. package/dist/vue/{RequestsSection-DLrjCfcE.js → RequestsSection-DXcG5Zok.js} +1 -1
  60. package/dist/vue/{RoutesSection-CPr9w42B.js → RoutesSection-BkNGWdoP.js} +1 -1
  61. package/dist/vue/components/Dashboard/sections/QueriesSection.vue.d.ts +1 -41
  62. package/dist/vue/{index-CYaqRGIT.js → index-CptF6Qbp.js} +2 -2
  63. package/dist/vue/index.js +1 -1
  64. package/dist/vue/style.css +1 -1
  65. package/package.json +1 -1
  66. package/dist/react/QueriesSection-CZJ-imAb.js +0 -474
  67. package/dist/react/QueriesTab-CQHa1ck3.js +0 -97
  68. package/dist/vue/QueriesSection-D2WGsuR4.js +0 -444
  69. package/dist/vue/QueriesTab-6D_xfi7Q.js +0 -114
@@ -1,444 +0,0 @@
1
- import { defineComponent as H, inject as A, ref as C, computed as $, openBlock as o, createElementBlock as i, createVNode as W, withCtx as it, createElementVNode as s, normalizeClass as y, unref as r, createTextVNode as v, toDisplayString as u, createCommentVNode as h, Fragment as k, renderList as T, withKeys as B, withModifiers as E, createBlock as ut, h as D } from "vue";
2
- import { formatTime as rt, timeAgo as dt, SLOW_DURATION_MS as pt, durationClassName as ct } from "adonisjs-server-stats/core";
3
- import { u as vt } from "./index-CYaqRGIT.js";
4
- import { u as ht } from "./useResizableTable-BoivAevK.js";
5
- import { _ as mt } from "./FilterBar.vue_vue_type_script_setup_true_lang-ClJ37hhT.js";
6
- import { _ as ft } from "./PaginationControls.vue_vue_type_script_setup_true_lang-CuN7g_8Z.js";
7
- const yt = { class: "ss-dash-btn-group" }, xt = {
8
- key: 0,
9
- class: "ss-dash-empty"
10
- }, _t = {
11
- key: 1,
12
- class: "ss-dash-table-wrap"
13
- }, bt = {
14
- key: 0,
15
- class: "ss-dash-sort-arrow"
16
- }, kt = {
17
- key: 0,
18
- class: "ss-dash-sort-arrow"
19
- }, wt = {
20
- key: 0,
21
- class: "ss-dash-sort-arrow"
22
- }, gt = ["onClick", "onKeydown"], Ct = {
23
- key: 0,
24
- class: "ss-dash-dup"
25
- }, $t = { style: { color: "var(--ss-muted)", "text-align": "center", display: "block" } }, Dt = { class: "ss-dash-duration" }, Nt = { class: "ss-dash-duration" }, Pt = { style: { color: "var(--ss-muted)", "text-align": "center", display: "block" } }, St = {
26
- key: 1,
27
- class: "ss-dash-empty"
28
- }, Tt = { class: "ss-dash-table-wrap" }, zt = {
29
- key: 0,
30
- class: "ss-dash-sort-arrow"
31
- }, jt = {
32
- key: 0,
33
- class: "ss-dash-sort-arrow"
34
- }, At = { style: { color: "var(--ss-dim)" } }, Ft = ["onClick", "onKeydown"], Kt = {
35
- key: 0,
36
- class: "ss-dash-dup"
37
- }, Lt = ["title"], Rt = { style: { color: "var(--ss-dim)", overflow: "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" } }, Et = ["title"], Mt = ["disabled", "onClick"], Ot = {
38
- key: 0,
39
- class: "ss-dash-explain-row"
40
- }, qt = {
41
- colspan: "8",
42
- class: "ss-dash-explain"
43
- }, Vt = { style: { display: "flex", "justify-content": "space-between", "align-items": "start" } }, Qt = { style: { flex: "1" } }, Ut = {
44
- key: 0,
45
- class: "ss-dash-explain-result ss-dash-explain-error"
46
- }, Wt = { key: 0 }, Bt = {
47
- key: 1,
48
- class: "ss-dash-explain-result"
49
- }, Ht = {
50
- key: 2,
51
- class: "ss-dash-explain-result"
52
- }, It = {
53
- key: 3,
54
- class: "ss-dash-explain-result"
55
- }, Jt = {
56
- key: 1,
57
- class: "ss-dash-empty"
58
- };
59
- function I(n, z) {
60
- if (!n) return null;
61
- const F = z * 20, K = n["Node Type"] || "Unknown", j = n["Relation Name"] || "", c = n.Alias && n.Alias !== n["Relation Name"] ? ` (${n.Alias})` : "", d = n["Index Name"] || "", a = [];
62
- if (n["Startup Cost"] !== null && n["Startup Cost"] !== void 0 && a.push(`cost=${n["Startup Cost"]}..${n["Total Cost"]}`), n["Plan Rows"] !== null && n["Plan Rows"] !== void 0 && a.push(`rows=${n["Plan Rows"]}`), n["Plan Width"] !== null && n["Plan Width"] !== void 0 && a.push(`width=${n["Plan Width"]}`), n.Filter && a.push(`filter: ${n.Filter}`), n["Index Cond"] && a.push(`cond: ${n["Index Cond"]}`), n["Hash Cond"] && a.push(`hash: ${n["Hash Cond"]}`), n["Join Type"] && a.push(`join: ${n["Join Type"]}`), n["Sort Key"]) {
63
- const N = Array.isArray(n["Sort Key"]) ? n["Sort Key"].join(", ") : n["Sort Key"];
64
- a.push(`sort: ${N}`);
65
- }
66
- const x = n.Plans || [];
67
- return D("div", { class: "ss-dash-explain-node", style: { marginLeft: `${F}px` } }, [
68
- D("div", { class: "ss-dash-explain-node-header" }, [
69
- D("span", { class: "ss-dash-explain-node-type" }, K),
70
- j ? [" on ", D("strong", null, j)] : null,
71
- c || null,
72
- d ? [" using ", D("em", null, d)] : null
73
- ]),
74
- a.length > 0 ? D("div", { class: "ss-dash-explain-metrics" }, a.join(" · ")) : null,
75
- ...x.map((N, w) => I(N, z + 1))
76
- ]);
77
- }
78
- const J = H({
79
- name: "ExplainPlanNode",
80
- props: {
81
- node: { type: Object, required: !0 },
82
- depth: { type: Number, default: 0 }
83
- },
84
- setup(n) {
85
- return () => I(n.node, n.depth);
86
- }
87
- }), Gt = { components: { ExplainPlanNode: J } }, ls = /* @__PURE__ */ H({
88
- ...Gt,
89
- __name: "QueriesSection",
90
- setup(n) {
91
- const z = A("ss-refresh-key", C(0)), F = A("ss-dashboard-endpoint", "/__stats/api"), K = A("ss-auth-token", void 0), j = A("ss-base-url", ""), c = C("list"), d = C(null), a = C(null), x = C(null), N = $(() => c.value === "grouped" ? "queries/grouped" : "queries"), { data: w, loading: G, pagination: P, sort: m, goToPage: X, setSearch: Y, setSort: Z, explainQuery: tt } = vt(() => N.value, {
92
- baseUrl: j,
93
- dashboardEndpoint: F,
94
- authToken: K,
95
- refreshKey: z
96
- }), M = C(""), O = $(() => w.value ? c.value === "grouped" ? w.value.groups || [] : w.value.data || w.value || [] : []), f = $(() => c.value !== "grouped" ? O.value : O.value.map((e) => {
97
- const t = { ...e };
98
- return (t.sqlNormalized === null || t.sqlNormalized === void 0 && (e.sql_normalized || e.pattern)) && (t.sqlNormalized = e.sql_normalized || e.pattern || ""), (t.count === null || t.count === void 0) && e.total_count !== null && e.total_count !== void 0 && (t.count = e.total_count), (t.avgDuration === null || t.avgDuration === void 0) && e.avg_duration !== null && e.avg_duration !== void 0 && (t.avgDuration = e.avg_duration), (t.maxDuration === null || t.maxDuration === void 0) && e.max_duration !== null && e.max_duration !== void 0 && (t.maxDuration = e.max_duration), (t.minDuration === null || t.minDuration === void 0) && e.min_duration !== null && e.min_duration !== void 0 && (t.minDuration = e.min_duration), (t.totalDuration === null || t.totalDuration === void 0) && e.total_duration !== null && e.total_duration !== void 0 && (t.totalDuration = e.total_duration), (t.percentOfTotal === null || t.percentOfTotal === void 0) && e.pct_time !== null && e.pct_time !== void 0 && (t.percentOfTotal = e.pct_time), t;
99
- })), L = $(() => {
100
- const e = /* @__PURE__ */ new Map();
101
- for (const t of f.value) {
102
- const l = t.sqlNormalized || t.sql || t.sql_text || "";
103
- e.set(l, (e.get(l) || 0) + 1);
104
- }
105
- return e;
106
- }), g = $(() => {
107
- const e = P.total ?? f.value.length;
108
- let t = 0, l = 0, p = 0, _ = 0;
109
- for (const b of f.value) {
110
- const U = b.duration || 0;
111
- p += U, _++, U > pt && t++;
112
- }
113
- for (const b of L.value.values())
114
- b > 1 && (l += b);
115
- return { total: e, slow: t, duplicates: l, avgDuration: _ > 0 ? p / _ : 0 };
116
- }), st = $(() => {
117
- if (c.value === "grouped") return `${f.value.length} query patterns`;
118
- const e = [`${g.value.total} queries`];
119
- return g.value.slow > 0 && e.push(`${g.value.slow} slow`), g.value.duplicates > 0 && e.push(`${g.value.duplicates} dup`), e.push(`avg ${(g.value.avgDuration || 0).toFixed(1)}ms`), e.join(", ");
120
- });
121
- function et(e) {
122
- M.value = e, Y(e);
123
- }
124
- function q(e) {
125
- e !== c.value && (c.value = e, d.value = null, a.value = null, x.value = null);
126
- }
127
- function S(e) {
128
- Z(e);
129
- }
130
- async function lt(e) {
131
- if (a.value && a.value.queryId === e) {
132
- a.value = null;
133
- return;
134
- }
135
- x.value = e;
136
- try {
137
- const t = await tt(e);
138
- t && t.error ? a.value = { queryId: e, plan: [], error: t.error, message: t.message } : a.value = { queryId: e, plan: t?.plan || t?.rows || [] };
139
- } catch (t) {
140
- a.value = {
141
- queryId: e,
142
- plan: [],
143
- error: t instanceof Error ? t.message : String(t)
144
- };
145
- } finally {
146
- x.value = null;
147
- }
148
- }
149
- function R(e) {
150
- return ct(e, "ss-dash");
151
- }
152
- function V() {
153
- const e = a.value?.plan;
154
- return !e || e.length === 0 || typeof e[0] != "object" || !e[0] ? [] : Object.keys(e[0]);
155
- }
156
- function nt(e, t) {
157
- if (!e || typeof e != "object") return "-";
158
- const l = e[t];
159
- return l != null ? String(l) : "-";
160
- }
161
- function at() {
162
- const e = a.value?.plan;
163
- return !e || e.length === 0 || typeof e[0] != "object" || !e[0] ? !1 : "Plan" in e[0];
164
- }
165
- function ot() {
166
- const e = a.value?.plan;
167
- return !e || e.length === 0 || typeof e[0] != "object" || !e[0] ? {} : e[0].Plan;
168
- }
169
- const { tableRef: Q } = ht(() => f.value);
170
- return (e, t) => (o(), i("div", null, [
171
- W(mt, {
172
- "model-value": M.value,
173
- placeholder: "Filter queries...",
174
- summary: st.value,
175
- "onUpdate:modelValue": et
176
- }, {
177
- default: it(() => [
178
- s("div", yt, [
179
- s("button", {
180
- type: "button",
181
- class: y(`ss-dash-btn ${c.value === "list" ? "ss-dash-active" : ""}`),
182
- onClick: t[0] || (t[0] = (l) => q("list"))
183
- }, " List ", 2),
184
- s("button", {
185
- type: "button",
186
- class: y(`ss-dash-btn ${c.value === "grouped" ? "ss-dash-active" : ""}`),
187
- onClick: t[1] || (t[1] = (l) => q("grouped"))
188
- }, " Grouped ", 2)
189
- ])
190
- ]),
191
- _: 1
192
- }, 8, ["model-value", "summary"]),
193
- r(G) && !r(w) ? (o(), i("div", xt, "Loading queries...")) : c.value === "grouped" ? (o(), i("div", _t, [
194
- f.value.length > 0 ? (o(), i("table", {
195
- key: 0,
196
- ref_key: "tableRef",
197
- ref: Q,
198
- class: "ss-dash-table"
199
- }, [
200
- s("thead", null, [
201
- s("tr", null, [
202
- t[11] || (t[11] = s("th", null, "Pattern", -1)),
203
- s("th", {
204
- class: "ss-dash-sortable",
205
- onClick: t[2] || (t[2] = (l) => S("count"))
206
- }, [
207
- t[8] || (t[8] = v(" Count ", -1)),
208
- r(m).column === "count" ? (o(), i("span", bt, u(r(m).direction === "asc" ? " ▲" : " ▼"), 1)) : h("", !0)
209
- ]),
210
- s("th", {
211
- class: "ss-dash-sortable",
212
- onClick: t[3] || (t[3] = (l) => S("avgDuration"))
213
- }, [
214
- t[9] || (t[9] = v(" Avg ", -1)),
215
- r(m).column === "avgDuration" ? (o(), i("span", kt, u(r(m).direction === "asc" ? " ▲" : " ▼"), 1)) : h("", !0)
216
- ]),
217
- t[12] || (t[12] = s("th", null, "Min", -1)),
218
- t[13] || (t[13] = s("th", null, "Max", -1)),
219
- s("th", {
220
- class: "ss-dash-sortable",
221
- onClick: t[4] || (t[4] = (l) => S("totalDuration"))
222
- }, [
223
- t[10] || (t[10] = v(" Total ", -1)),
224
- r(m).column === "totalDuration" ? (o(), i("span", wt, u(r(m).direction === "asc" ? " ▲" : " ▼"), 1)) : h("", !0)
225
- ]),
226
- t[14] || (t[14] = s("th", null, "% Time", -1))
227
- ])
228
- ]),
229
- s("tbody", null, [
230
- (o(!0), i(k, null, T(f.value, (l, p) => (o(), i("tr", { key: p }, [
231
- s("td", null, [
232
- s("span", {
233
- class: y(`ss-dash-sql ${d.value === l.sqlNormalized ? "ss-dash-expanded" : ""}`),
234
- title: "Click to expand",
235
- role: "button",
236
- tabindex: "0",
237
- onClick: E((_) => d.value = d.value === l.sqlNormalized ? null : l.sqlNormalized, ["stop"]),
238
- onKeydown: B((_) => d.value = d.value === l.sqlNormalized ? null : l.sqlNormalized, ["enter"])
239
- }, u(l.sqlNormalized), 43, gt),
240
- (l.count || 0) >= 3 ? (o(), i("span", Ct, "DUP")) : h("", !0)
241
- ]),
242
- s("td", null, [
243
- s("span", $t, u(l.count || 0), 1)
244
- ]),
245
- s("td", null, [
246
- s("span", {
247
- class: y(`ss-dash-duration ${R(l.avgDuration || 0)}`)
248
- }, u((l.avgDuration || 0).toFixed(2)) + "ms ", 3)
249
- ]),
250
- s("td", null, [
251
- s("span", Dt, u((l.minDuration || 0).toFixed(2)) + "ms", 1)
252
- ]),
253
- s("td", null, [
254
- s("span", {
255
- class: y(`ss-dash-duration ${R(l.maxDuration || 0)}`)
256
- }, u((l.maxDuration || 0).toFixed(2)) + "ms ", 3)
257
- ]),
258
- s("td", null, [
259
- s("span", Nt, u((l.totalDuration || 0).toFixed(1)) + "ms", 1)
260
- ]),
261
- s("td", null, [
262
- s("span", Pt, u((l.percentOfTotal || 0).toFixed(1)) + "%", 1)
263
- ])
264
- ]))), 128))
265
- ])
266
- ], 512)) : (o(), i("div", St, [...t[15] || (t[15] = [
267
- s("span", null, "No queries recorded", -1),
268
- s("span", { class: "ss-empty-hint" }, [
269
- v(" Queries require "),
270
- s("code", null, "debug: true"),
271
- v(" on your Lucid connections in "),
272
- s("code", null, "config/database.ts")
273
- ], -1)
274
- ])]))
275
- ])) : (o(), i(k, { key: 2 }, [
276
- s("div", Tt, [
277
- f.value.length > 0 ? (o(), i("table", {
278
- key: 0,
279
- ref_key: "tableRef",
280
- ref: Q,
281
- class: "ss-dash-table"
282
- }, [
283
- t[25] || (t[25] = s("colgroup", null, [
284
- s("col", { style: { width: "40px" } }),
285
- s("col"),
286
- s("col", { style: { width: "70px" } }),
287
- s("col", { style: { width: "60px" } }),
288
- s("col", { style: { width: "90px" } }),
289
- s("col", { style: { width: "80px" } }),
290
- s("col", { style: { width: "90px" } }),
291
- s("col", { style: { width: "70px" } })
292
- ], -1)),
293
- s("thead", null, [
294
- s("tr", null, [
295
- t[18] || (t[18] = s("th", null, "#", -1)),
296
- t[19] || (t[19] = s("th", null, "SQL", -1)),
297
- s("th", {
298
- class: "ss-dash-sortable",
299
- onClick: t[5] || (t[5] = (l) => S("duration"))
300
- }, [
301
- t[16] || (t[16] = v(" Duration ", -1)),
302
- r(m).column === "duration" ? (o(), i("span", zt, u(r(m).direction === "asc" ? " ▲" : " ▼"), 1)) : h("", !0)
303
- ]),
304
- t[20] || (t[20] = s("th", null, "Method", -1)),
305
- t[21] || (t[21] = s("th", null, "Model", -1)),
306
- t[22] || (t[22] = s("th", null, "Connection", -1)),
307
- s("th", {
308
- class: "ss-dash-sortable",
309
- onClick: t[6] || (t[6] = (l) => S("createdAt"))
310
- }, [
311
- t[17] || (t[17] = v(" Time ", -1)),
312
- r(m).column === "createdAt" ? (o(), i("span", jt, u(r(m).direction === "asc" ? " ▲" : " ▼"), 1)) : h("", !0)
313
- ]),
314
- t[23] || (t[23] = s("th", null, null, -1))
315
- ])
316
- ]),
317
- s("tbody", null, [
318
- (o(!0), i(k, null, T(f.value, (l) => (o(), i(k, {
319
- key: l.id
320
- }, [
321
- s("tr", null, [
322
- s("td", null, [
323
- s("span", At, u(l.id), 1)
324
- ]),
325
- s("td", null, [
326
- s("div", null, [
327
- s("span", {
328
- class: y(`ss-dash-sql ${d.value === l.id ? "ss-dash-expanded" : ""}`),
329
- title: "Click to expand",
330
- role: "button",
331
- tabindex: "0",
332
- onClick: E((p) => d.value = d.value === l.id ? null : l.id, ["stop"]),
333
- onKeydown: B((p) => d.value = d.value === l.id ? null : l.id, ["enter"])
334
- }, u(l.sql || l.sql_text || ""), 43, Ft),
335
- (L.value.get(
336
- (l.sqlNormalized || l.sql || l.sql_text) ?? ""
337
- ) ?? 0) > 1 ? (o(), i("span", Kt, " ×" + u(L.value.get(
338
- (l.sqlNormalized || l.sql || l.sql_text) ?? ""
339
- )), 1)) : h("", !0)
340
- ])
341
- ]),
342
- s("td", null, [
343
- s("span", {
344
- class: y(`ss-dash-duration ${R(l.duration || 0)}`)
345
- }, u((l.duration || 0).toFixed(2)) + "ms ", 3)
346
- ]),
347
- s("td", null, [
348
- s("span", {
349
- class: y(`ss-dash-method ss-dash-method-${(l.method || l.sql_method || "").toLowerCase()}`)
350
- }, u(l.method || l.sql_method || ""), 3)
351
- ]),
352
- s("td", null, [
353
- s("span", {
354
- style: { color: "var(--ss-muted)", overflow: "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" },
355
- title: l.model
356
- }, u(l.model || "-"), 9, Lt)
357
- ]),
358
- s("td", null, [
359
- s("span", Rt, u(l.connection || "-"), 1)
360
- ]),
361
- s("td", null, [
362
- s("span", {
363
- class: "ss-dash-event-time",
364
- title: r(rt)(
365
- l.createdAt || l.created_at || l.timestamp || ""
366
- )
367
- }, u(r(dt)(
368
- l.createdAt || l.created_at || l.timestamp || ""
369
- )), 9, Et)
370
- ]),
371
- s("td", null, [
372
- (l.method || l.sql_method || "") === "select" ? (o(), i("button", {
373
- key: 0,
374
- type: "button",
375
- class: y(`ss-dash-explain-btn${a.value?.queryId === l.id && !a.value?.error ? " ss-dash-explain-btn-active" : ""}`),
376
- disabled: x.value === l.id,
377
- onClick: E((p) => lt(l.id), ["stop"])
378
- }, u(x.value === l.id ? "..." : "EXPLAIN"), 11, Mt)) : h("", !0)
379
- ])
380
- ]),
381
- a.value && a.value.queryId === l.id ? (o(), i("tr", Ot, [
382
- s("td", qt, [
383
- s("div", Vt, [
384
- s("div", Qt, [
385
- a.value.error ? (o(), i("div", Ut, [
386
- t[24] || (t[24] = s("strong", null, "Error:", -1)),
387
- v(" " + u(a.value.error) + " ", 1),
388
- a.value.message ? (o(), i("br", Wt)) : h("", !0),
389
- v(" " + u(a.value.message), 1)
390
- ])) : at() ? (o(), i("div", Bt, [
391
- W(r(J), {
392
- node: ot(),
393
- depth: 0
394
- }, null, 8, ["node"])
395
- ])) : a.value.plan && a.value.plan.length > 0 && typeof a.value.plan[0] == "object" ? (o(), i("div", Ht, [
396
- s("table", null, [
397
- s("thead", null, [
398
- s("tr", null, [
399
- (o(!0), i(k, null, T(V(), (p) => (o(), i("th", { key: p }, u(p), 1))), 128))
400
- ])
401
- ]),
402
- s("tbody", null, [
403
- (o(!0), i(k, null, T(a.value.plan, (p, _) => (o(), i("tr", { key: _ }, [
404
- (o(!0), i(k, null, T(V(), (b) => (o(), i("td", { key: b }, u(nt(p, b)), 1))), 128))
405
- ]))), 128))
406
- ])
407
- ])
408
- ])) : (o(), i("div", It, "No plan data returned"))
409
- ]),
410
- s("button", {
411
- type: "button",
412
- class: "ss-dash-explain-btn",
413
- style: { "margin-left": "8px", "flex-shrink": "0" },
414
- onClick: t[7] || (t[7] = (p) => a.value = null)
415
- }, " Close ")
416
- ])
417
- ])
418
- ])) : h("", !0)
419
- ], 64))), 128))
420
- ])
421
- ], 512)) : (o(), i("div", Jt, [...t[26] || (t[26] = [
422
- s("span", null, "No queries recorded", -1),
423
- s("span", { class: "ss-empty-hint" }, [
424
- v(" Queries require "),
425
- s("code", null, "debug: true"),
426
- v(" on your Lucid connections in "),
427
- s("code", null, "config/database.ts")
428
- ], -1)
429
- ])]))
430
- ]),
431
- r(P).totalPages > 1 ? (o(), ut(ft, {
432
- key: 0,
433
- page: r(P).page,
434
- "last-page": r(P).totalPages,
435
- total: r(P).total,
436
- onPageChange: r(X)
437
- }, null, 8, ["page", "last-page", "total", "onPageChange"])) : h("", !0)
438
- ], 64))
439
- ]));
440
- }
441
- });
442
- export {
443
- ls as default
444
- };
@@ -1,114 +0,0 @@
1
- import { defineComponent as $, ref as D, computed as r, openBlock as a, createElementBlock as l, createElementVNode as e, withDirectives as N, vModelText as S, toDisplayString as n, createTextVNode as f, Fragment as E, renderList as L, withKeys as V, normalizeClass as h, createCommentVNode as y, unref as b } from "vue";
2
- import { filterQueries as A, countDuplicateQueries as K, computeQuerySummary as M, formatDuration as _, formatTime as R, timeAgo as z, durationClassName as B } from "adonisjs-server-stats/core";
3
- import { u as F } from "./useResizableTable-BoivAevK.js";
4
- const I = { class: "ss-dbg-search-bar" }, P = { class: "ss-dbg-summary" }, U = {
5
- key: 0,
6
- class: "ss-dbg-empty"
7
- }, X = {
8
- class: "ss-dbg-c-dim",
9
- style: { "white-space": "nowrap" }
10
- }, j = ["onClick", "onKeydown"], G = {
11
- key: 0,
12
- class: "ss-dbg-dup"
13
- }, H = {
14
- key: 1,
15
- class: "ss-dbg-dup"
16
- }, J = { class: "ss-dbg-c-muted" }, O = ["title"], q = /* @__PURE__ */ $({
17
- __name: "QueriesTab",
18
- props: {
19
- data: {},
20
- dashboardPath: {}
21
- },
22
- setup(C) {
23
- const v = C, c = D(""), i = /* @__PURE__ */ new Set(), m = r(() => {
24
- if (!v.data) return [];
25
- const s = v.data;
26
- return (Array.isArray(s) ? s : s.queries) || [];
27
- }), u = r(() => A(m.value, c.value)), p = r(() => K(m.value)), d = r(() => M(m.value, p.value)), w = r(() => {
28
- let s = `${u.value.length} queries`;
29
- return d.value.slowCount > 0 && (s += ` | ${d.value.slowCount} slow`), d.value.dupCount > 0 && (s += ` | ${d.value.dupCount} dup`), u.value.length > 0 && (s += ` | avg ${_(d.value.avgDuration)}`), s;
30
- });
31
- function g(s) {
32
- i.has(s) ? i.delete(s) : i.add(s);
33
- }
34
- function x(s) {
35
- return i.has(s);
36
- }
37
- function k(s) {
38
- return B(s, "ss-dbg");
39
- }
40
- const { tableRef: T } = F(() => u.value);
41
- return (s, o) => (a(), l("div", null, [
42
- e("div", I, [
43
- N(e("input", {
44
- "onUpdate:modelValue": o[0] || (o[0] = (t) => c.value = t),
45
- class: "ss-dbg-search",
46
- placeholder: "Filter queries...",
47
- type: "text"
48
- }, null, 512), [
49
- [S, c.value]
50
- ]),
51
- e("span", P, n(w.value), 1)
52
- ]),
53
- u.value.length === 0 ? (a(), l("div", U, [...o[1] || (o[1] = [
54
- e("span", null, "No queries captured", -1),
55
- e("span", { class: "ss-empty-hint" }, [
56
- f(" Queries require "),
57
- e("code", null, "debug: true"),
58
- f(" on your Lucid connections in "),
59
- e("code", null, "config/database.ts")
60
- ], -1)
61
- ])])) : (a(), l("table", {
62
- key: 1,
63
- ref_key: "tableRef",
64
- ref: T,
65
- class: "ss-dbg-table"
66
- }, [
67
- o[2] || (o[2] = e("thead", null, [
68
- e("tr", null, [
69
- e("th", null, "#"),
70
- e("th", null, "SQL"),
71
- e("th", null, "Duration"),
72
- e("th", null, "Method"),
73
- e("th", null, "Model"),
74
- e("th", null, "Time")
75
- ])
76
- ], -1)),
77
- e("tbody", null, [
78
- (a(!0), l(E, null, L(u.value, (t) => (a(), l("tr", {
79
- key: t.id
80
- }, [
81
- e("td", X, n(t.id), 1),
82
- e("td", null, [
83
- e("span", {
84
- class: h(["ss-dbg-sql", { "ss-dbg-expanded": x(t.id) }]),
85
- role: "button",
86
- tabindex: "0",
87
- onClick: (Q) => g(t.id),
88
- onKeydown: V((Q) => g(t.id), ["enter"])
89
- }, n(t.sql), 43, j),
90
- p.value[t.sql] > 1 ? (a(), l("span", G, " x" + n(p.value[t.sql]), 1)) : y("", !0),
91
- t.inTransaction ? (a(), l("span", H, " TXN")) : y("", !0)
92
- ]),
93
- e("td", {
94
- class: h(["ss-dbg-duration", k(t.duration)])
95
- }, n(b(_)(t.duration)), 3),
96
- e("td", null, [
97
- e("span", {
98
- class: h(`ss-dbg-method ss-dbg-method-${t.method.toLowerCase()}`)
99
- }, n(t.method), 3)
100
- ]),
101
- e("td", J, n(t.model || "-"), 1),
102
- e("td", {
103
- class: "ss-dbg-event-time",
104
- title: b(R)(t.timestamp)
105
- }, n(b(z)(t.timestamp)), 9, O)
106
- ]))), 128))
107
- ])
108
- ], 512))
109
- ]));
110
- }
111
- });
112
- export {
113
- q as default
114
- };