From 18e920fe54094d6d4682d989271ce12089c35ffd Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 11 Apr 2026 16:34:08 -0500 Subject: [PATCH] Fix backfill page missing partitioned table stats, fix contacts map init Backfill page now sums child partition stats for partitioned tables like hrrr_profiles (relkind 'p') which were excluded by the relkind 'r' filter. Contacts map defers Leaflet init to requestAnimationFrame so the flex container has dimensions before map initialization. --- assets/js/contacts_map_hook.js | 19 ++++++++++++------- lib/microwaveprop_web/live/backfill_live.ex | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/assets/js/contacts_map_hook.js b/assets/js/contacts_map_hook.js index 71de8ce2..67dd386b 100644 --- a/assets/js/contacts_map_hook.js +++ b/assets/js/contacts_map_hook.js @@ -34,6 +34,18 @@ export const ContactsMap = { this.lineLayer = L.layerGroup() this.dotLayer = L.layerGroup() + // Listen for filter changes from LiveView + this.handleEvent("apply_filter", ({enabled_bands, callsign}) => { + this.enabledBands = new Set(enabled_bands) + this.callsignFilter = (callsign || "").toUpperCase() + this.rebuildMap() + }) + + // Defer map init until container has dimensions + requestAnimationFrame(() => this.initMap()) + }, + + initMap() { this.map = L.map(this.el, { center: [37.5, -96], zoom: 5, @@ -53,13 +65,6 @@ export const ContactsMap = { // Enable all bands initially for (const c of this.allContacts) this.enabledBands.add(c[4]) - // Listen for filter changes from LiveView - this.handleEvent("apply_filter", ({enabled_bands, callsign}) => { - this.enabledBands = new Set(enabled_bands) - this.callsignFilter = (callsign || "").toUpperCase() - this.rebuildMap() - }) - this.rebuildMap() }, diff --git a/lib/microwaveprop_web/live/backfill_live.ex b/lib/microwaveprop_web/live/backfill_live.ex index 738f7aac..8f84020e 100644 --- a/lib/microwaveprop_web/live/backfill_live.ex +++ b/lib/microwaveprop_web/live/backfill_live.ex @@ -185,6 +185,7 @@ defmodule MicrowavepropWeb.BackfillLive do end defp fetch_db_stats do + # Regular tables + partitioned tables (summing child partition stats) %{rows: rows} = Repo.query!(""" SELECT @@ -199,7 +200,21 @@ defmodule MicrowavepropWeb.BackfillLive do AND c.relkind = 'r' AND c.relname NOT LIKE 'oban_%' AND c.relname NOT LIKE 'schema_%' - ORDER BY pg_total_relation_size(c.oid) DESC + AND NOT EXISTS (SELECT 1 FROM pg_inherits WHERE inhrelid = c.oid) + UNION ALL + SELECT + parent.relname, + COALESCE(SUM(cs.n_live_tup), 0)::bigint, + COALESCE(SUM(cs.n_dead_tup), 0)::bigint, + COALESCE(SUM(pg_total_relation_size(child.oid)), 0)::bigint + FROM pg_class parent + JOIN pg_namespace n ON n.oid = parent.relnamespace + JOIN pg_inherits inh ON inh.inhparent = parent.oid + JOIN pg_class child ON child.oid = inh.inhrelid + LEFT JOIN pg_stat_user_tables cs ON cs.relid = child.oid + WHERE n.nspname = 'public' AND parent.relkind = 'p' + GROUP BY parent.relname + ORDER BY bytes DESC LIMIT 20 """)