diff --git a/app/templates/dashboard/ceo.html b/app/templates/dashboard/ceo.html index 4315a64..cc06113 100644 --- a/app/templates/dashboard/ceo.html +++ b/app/templates/dashboard/ceo.html @@ -218,15 +218,22 @@ }); this.charts.monthlyMax = Math.max(...this.charts.monthlyTrend.map(m => m.count), 1); - // By property + // By property — load units once and compute from ticket data const propData = { east: 0, west: 0 }; - all.forEach(t => { /* would need unit join — estimate from ticket IDs */ }); try { - const east = await app().apiGet('/api/tickets?property=East&page_size=1'); - const west = await app().apiGet('/api/tickets?property=West&page_size=1'); - propData.east = east?.total || 0; - propData.west = west?.total || 0; - } catch (e) { /* api may not support property filter directly */ } + const units = await app().apiGet('/api/tickets/units'); + if (units && units.length > 0) { + const unitPropertyMap = {}; + units.forEach(u => { unitPropertyMap[u.id] = u.property; }); + all.forEach(t => { + if (t.unit_id && unitPropertyMap[t.unit_id]) { + const p = unitPropertyMap[t.unit_id].toLowerCase(); + if (p === 'east') propData.east++; + else if (p === 'west') propData.west++; + } + }); + } + } catch (e) { console.error('Property stats error', e); } this.charts.byProperty = { east: propData.east, west: propData.west, max: Math.max(propData.east, propData.west, 1) }; // By category — use categories endpoint diff --git a/app/templates/tickets/detail.html b/app/templates/tickets/detail.html index c933a3a..b722ec5 100644 --- a/app/templates/tickets/detail.html +++ b/app/templates/tickets/detail.html @@ -115,7 +115,7 @@