dbviewer 0.7.4 → 0.7.5
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/dbviewer/home.js +78 -74
- data/lib/dbviewer/query/parser.rb +6 -1
- data/lib/dbviewer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27da0a6d3d08f2a6d1a597c1f7e688a54ffec7048e135b30a605ee3ace20370e
|
4
|
+
data.tar.gz: 2e59f9c1c69b2bb87c7d9a351a045cfaea9709dc49ce7651d8ef24821db43aa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48a192e9bdd118358734a2b5008a87e7219fb224b95c897601b5e448c513027b4d14b816d9abcef3950540cb99cb97af991a3f58325359592179e8dc9e2d0752
|
7
|
+
data.tar.gz: f3dacb78ba4309d724c7c469e4ff00457921e97d567f808a14cfe48efb38d45fadee7303f31c8f6e326037f8de27783302561acd0b84e4d42487bada7da8fed8
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener("DOMContentLoaded", function () {
|
1
|
+
document.addEventListener("DOMContentLoaded", async function () {
|
2
2
|
// Helper function to format numbers with commas
|
3
3
|
function numberWithDelimiter(number) {
|
4
4
|
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
@@ -24,13 +24,6 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
24
24
|
data.total_tables || 0;
|
25
25
|
}
|
26
26
|
|
27
|
-
function updateRelationshipsCount(data) {
|
28
|
-
document.getElementById("relationships-loading").classList.add("d-none");
|
29
|
-
document.getElementById("relationships-count").classList.remove("d-none");
|
30
|
-
document.getElementById("relationships-count").textContent =
|
31
|
-
data.total_relationships || 0;
|
32
|
-
}
|
33
|
-
|
34
27
|
function updateDatabaseSize(data) {
|
35
28
|
document.getElementById("size-loading").classList.add("d-none");
|
36
29
|
document.getElementById("size-count").classList.remove("d-none");
|
@@ -186,102 +179,113 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
186
179
|
`;
|
187
180
|
}
|
188
181
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
182
|
+
async function fetchTableCount() {
|
183
|
+
try {
|
184
|
+
const response = await fetch(
|
185
|
+
document.getElementById("api_tables_path").value,
|
186
|
+
{
|
187
|
+
headers: {
|
188
|
+
Accept: "application/json",
|
189
|
+
"X-Requested-With": "XMLHttpRequest",
|
190
|
+
},
|
191
|
+
}
|
192
|
+
);
|
197
193
|
if (!response.ok) {
|
198
194
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
199
195
|
}
|
200
|
-
|
201
|
-
})
|
202
|
-
.then((data) => {
|
196
|
+
const data = await response.json();
|
203
197
|
updateTablesCount(data);
|
204
|
-
})
|
205
|
-
.catch((error) => {
|
198
|
+
} catch (error) {
|
206
199
|
console.error("Error loading tables count:", error);
|
207
200
|
const loading = document.getElementById("tables-loading");
|
208
201
|
const count = document.getElementById("tables-count");
|
209
202
|
loading.classList.add("d-none");
|
210
203
|
count.classList.remove("d-none");
|
211
204
|
count.innerHTML = '<span class="text-danger">Error</span>';
|
212
|
-
}
|
205
|
+
}
|
206
|
+
}
|
213
207
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
208
|
+
async function fetchDatabaseSize() {
|
209
|
+
try {
|
210
|
+
const response = await fetch(
|
211
|
+
document.getElementById("size_api_database_path").value,
|
212
|
+
{
|
213
|
+
headers: {
|
214
|
+
Accept: "application/json",
|
215
|
+
"X-Requested-With": "XMLHttpRequest",
|
216
|
+
},
|
217
|
+
}
|
218
|
+
);
|
222
219
|
if (!response.ok) {
|
223
220
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
224
221
|
}
|
225
|
-
|
226
|
-
})
|
227
|
-
.then((data) => {
|
222
|
+
const data = await response.json();
|
228
223
|
updateDatabaseSize(data);
|
229
|
-
})
|
230
|
-
.catch((error) => {
|
224
|
+
} catch (error) {
|
231
225
|
console.error("Error loading database size:", error);
|
232
226
|
const loading = document.getElementById("size-loading");
|
233
227
|
const count = document.getElementById("size-count");
|
234
228
|
loading.classList.add("d-none");
|
235
229
|
count.classList.remove("d-none");
|
236
230
|
count.innerHTML = '<span class="text-danger">Error</span>';
|
237
|
-
}
|
231
|
+
}
|
232
|
+
}
|
238
233
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
234
|
+
async function fetchRecordsCount() {
|
235
|
+
try {
|
236
|
+
const response = await fetch(
|
237
|
+
document.getElementById("records_api_tables_path").value,
|
238
|
+
{
|
239
|
+
headers: {
|
240
|
+
Accept: "application/json",
|
241
|
+
"X-Requested-With": "XMLHttpRequest",
|
242
|
+
},
|
243
|
+
}
|
244
|
+
);
|
247
245
|
if (!response.ok) {
|
248
246
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
249
247
|
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
recordsCount.classList.remove("d-none");
|
262
|
-
recordsCount.innerHTML = '<span class="text-danger">Error</span>';
|
263
|
-
|
264
|
-
showError("largest-tables-container", error.message);
|
265
|
-
});
|
248
|
+
const data = await response.json();
|
249
|
+
updateRecordsData(data);
|
250
|
+
} catch (error) {
|
251
|
+
console.error("Error loading records count:", error);
|
252
|
+
const loading = document.getElementById("records-loading");
|
253
|
+
const count = document.getElementById("records-count");
|
254
|
+
loading.classList.add("d-none");
|
255
|
+
count.classList.remove("d-none");
|
256
|
+
count.innerHTML = '<span class="text-danger">Error</span>';
|
257
|
+
}
|
258
|
+
}
|
266
259
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
260
|
+
async function fetchRecentQueries() {
|
261
|
+
try {
|
262
|
+
const response = await fetch(
|
263
|
+
document.getElementById("recent_api_queries_path").value,
|
264
|
+
{
|
265
|
+
headers: {
|
266
|
+
Accept: "application/json",
|
267
|
+
"X-Requested-With": "XMLHttpRequest",
|
268
|
+
},
|
269
|
+
}
|
270
|
+
);
|
275
271
|
if (!response.ok) {
|
276
272
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
277
273
|
}
|
278
|
-
|
279
|
-
})
|
280
|
-
.then((data) => {
|
274
|
+
const data = await response.json();
|
281
275
|
updateRecentQueries(data);
|
282
|
-
})
|
283
|
-
.catch((error) => {
|
276
|
+
} catch (error) {
|
284
277
|
console.error("Error loading recent queries:", error);
|
285
278
|
showError("recent-queries-container", error.message);
|
286
|
-
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
// Load database size data (Loading records first to prevent race condition on dbviewer model constant creation)
|
282
|
+
await fetchRecordsCount();
|
283
|
+
|
284
|
+
Promise.all([
|
285
|
+
fetchTableCount(),
|
286
|
+
fetchDatabaseSize(),
|
287
|
+
fetchRecentQueries(),
|
288
|
+
]).catch((error) => {
|
289
|
+
console.error("Error loading initial data:", error);
|
290
|
+
});
|
287
291
|
});
|
@@ -62,7 +62,12 @@ module Dbviewer
|
|
62
62
|
# @return [Boolean] True if the query should be skipped
|
63
63
|
def self.should_skip_internal_query?(event)
|
64
64
|
event.payload[:name].include?("Dbviewer::") ||
|
65
|
-
|
65
|
+
# SQLite specific check for size queries
|
66
|
+
event.payload[:sql].include?("PRAGMA") ||
|
67
|
+
# PostgreSQL specific check for size queries
|
68
|
+
event.payload[:sql].include?("pg_database_size(current_database())") ||
|
69
|
+
# MySQL specific check for size queries
|
70
|
+
event.payload[:sql].include?("SUM(data_length + index_length) AS size FROM information_schema.TABLES")
|
66
71
|
end
|
67
72
|
end
|
68
73
|
end
|
data/lib/dbviewer/version.rb
CHANGED