Dashboard stats/chart minor cleanup: missing empty-state message, dead duplicate click-handler, dead computed field #101

Open
opened 2026-09-01 00:13:39 -04:00 by jared · 0 comments
Owner

Severity: Low (bundled cleanup — three small findings from the same audit pass)

  1. Charts render a bare empty frame with no message when the filtered dataset is empty. views/DashboardView.php (makeDonut/makeBar, ~lines 336, 369) — if (!ctx || !data.length) return; silently skips chart creation. Reachable on a fresh install, or when a non-admin's visibility-filtered ticket set happens to be zero. Fix: render a simple "No data for current filters" message in the chart's place.

  2. Stat cards have two independent, redundant click-handler implementations — one is dead code with misleading HTML attributes. assets/js/base.js (lt.statsFilter.init(), ~lines 608-628) reads each card's data-filter-key/data-filter-val attributes and calls window.lt_onStatFilter(key, val) on click — but that global function is never defined anywhere in the app (confirmed via grep), so this handler only toggles a cosmetic .active class with no functional effect. The actual navigation logic is a completely separate, duplicated handler at DashboardView.php (~lines 1280-1293) that ignores the data-filter-key/data-filter-val attributes entirely. Both fire on the same click today with no visible symptom (the real handler navigates away before anyone would notice), but the markup looks load-bearing and isn't — a trap for a future edit that touches one implementation assuming it's the only one. Fix: delete the dead lt.statsFilter handler and the now-unused data-filter-key/data-filter-val attributes, since the real logic lives entirely in DashboardView.php.

  3. created_this_week is computed in StatsModel::fetchAllStats()'s counts query on every single request but is never displayed or read anywhere in the UI — dead computed field, harmless but wasted query work on every dashboard load. Fix: remove it from the query if genuinely unused, or wire it into a widget if it was meant to be shown.

**Severity:** Low (bundled cleanup — three small findings from the same audit pass) 1. **Charts render a bare empty frame with no message when the filtered dataset is empty.** `views/DashboardView.php` (`makeDonut`/`makeBar`, ~lines 336, 369) — `if (!ctx || !data.length) return;` silently skips chart creation. Reachable on a fresh install, or when a non-admin's visibility-filtered ticket set happens to be zero. Fix: render a simple "No data for current filters" message in the chart's place. 2. **Stat cards have two independent, redundant click-handler implementations — one is dead code with misleading HTML attributes.** `assets/js/base.js` (`lt.statsFilter.init()`, ~lines 608-628) reads each card's `data-filter-key`/`data-filter-val` attributes and calls `window.lt_onStatFilter(key, val)` on click — but that global function is never defined anywhere in the app (confirmed via grep), so this handler only toggles a cosmetic `.active` class with no functional effect. The actual navigation logic is a completely separate, duplicated handler at `DashboardView.php` (~lines 1280-1293) that ignores the `data-filter-key`/`data-filter-val` attributes entirely. Both fire on the same click today with no visible symptom (the real handler navigates away before anyone would notice), but the markup looks load-bearing and isn't — a trap for a future edit that touches one implementation assuming it's the only one. Fix: delete the dead `lt.statsFilter` handler and the now-unused `data-filter-key`/`data-filter-val` attributes, since the real logic lives entirely in `DashboardView.php`. 3. **`created_this_week` is computed in `StatsModel::fetchAllStats()`'s counts query on every single request but is never displayed or read anywhere in the UI** — dead computed field, harmless but wasted query work on every dashboard load. Fix: remove it from the query if genuinely unused, or wire it into a widget if it was meant to be shown.
jared added the dead-codepriority/lowux labels 2026-09-08 10:15:50 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/tinker_tickets#101