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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 243466a78ac9698ebe99e2f1cc225355bcb278eced6d87da6ca6d4cc87a636ba
4
- data.tar.gz: eb7006f0fb710d799f9167f1f8a8081f6850c46e9bc9ed8d40245ca16024ffdc
3
+ metadata.gz: 27da0a6d3d08f2a6d1a597c1f7e688a54ffec7048e135b30a605ee3ace20370e
4
+ data.tar.gz: 2e59f9c1c69b2bb87c7d9a351a045cfaea9709dc49ce7651d8ef24821db43aa7
5
5
  SHA512:
6
- metadata.gz: f41b5f67b69a22e98a008c3e686c91a369428dc2d57beab21c429cf6ff9dca371cfa546c91a063db62e109819b4c3ff3ba1a6a3e0a333cf55f6e8e7d6f318ead
7
- data.tar.gz: fd3467c65880b1f5b187537b7a10bdac6b971846704da02212f1dd04bf8f73c0f1d2ce355310f804c8fcb56d3f04da64ef9bca562027bf60958fc400bc1ee6b9
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
- // Load tables count data
190
- fetch(document.getElementById("api_tables_path").value, {
191
- headers: {
192
- Accept: "application/json",
193
- "X-Requested-With": "XMLHttpRequest",
194
- },
195
- })
196
- .then((response) => {
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
- return response.json();
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
- // Load database size data
215
- fetch(document.getElementById("size_api_database_path").value, {
216
- headers: {
217
- Accept: "application/json",
218
- "X-Requested-With": "XMLHttpRequest",
219
- },
220
- })
221
- .then((response) => {
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
- return response.json();
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
- // Load records data separately
240
- fetch(document.getElementById("records_api_tables_path").value, {
241
- headers: {
242
- Accept: "application/json",
243
- "X-Requested-With": "XMLHttpRequest",
244
- },
245
- })
246
- .then((response) => {
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
- return response.json();
251
- })
252
- .then((recordsData) => {
253
- updateRecordsData(recordsData);
254
- })
255
- .catch((error) => {
256
- console.error("Error loading records data:", error);
257
- // Update records-related UI with error state
258
- const recordsLoading = document.getElementById("records-loading");
259
- const recordsCount = document.getElementById("records-count");
260
- recordsLoading.classList.add("d-none");
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
- // Load recent queries data
268
- fetch(document.getElementById("recent_api_queries_path").value, {
269
- headers: {
270
- Accept: "application/json",
271
- "X-Requested-With": "XMLHttpRequest",
272
- },
273
- })
274
- .then((response) => {
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
- return response.json();
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
- event.payload[:sql].include?("PRAGMA")
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
@@ -1,3 +1,3 @@
1
1
  module Dbviewer
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbviewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wailan Tirajoh