Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
56ec008
1
Parent(s): eb2bcc8
nexus: unify dashboard data sources and fix status aggregation
Browse files
api/v1/dashboard.py
CHANGED
|
@@ -96,10 +96,15 @@ async def get_dashboard_stats(
|
|
| 96 |
|
| 97 |
stmt = stmt.group_by(Ticket.status)
|
| 98 |
counts_res = await db.execute(stmt)
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
| 100 |
for s in TicketStatus:
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
|
| 104 |
prio_stmt = select(Ticket.priority, func.count(Ticket.id)).where(Ticket.deleted_at.is_(None))
|
| 105 |
if not is_global: prio_stmt = prio_stmt.where(Ticket.workspace_id == target_ws)
|
|
@@ -218,7 +223,8 @@ async def get_dashboard_stats(
|
|
| 218 |
|
| 219 |
# 5. Final Sanitization (Nexus Privacy Layer)
|
| 220 |
response = {
|
| 221 |
-
"total_tickets":
|
|
|
|
| 222 |
"by_status": counts,
|
| 223 |
"by_priority": prio_counts,
|
| 224 |
"by_category": cat_counts,
|
|
|
|
| 96 |
|
| 97 |
stmt = stmt.group_by(Ticket.status)
|
| 98 |
counts_res = await db.execute(stmt)
|
| 99 |
+
# Ensure keys are strings for JSON consistency
|
| 100 |
+
counts = {str(row[0].value if hasattr(row[0], 'value') else row[0]).upper(): row[1] for row in counts_res.all()}
|
| 101 |
+
|
| 102 |
+
# Backfill missing statuses with 0
|
| 103 |
for s in TicketStatus:
|
| 104 |
+
s_key = str(s.value).upper()
|
| 105 |
+
if s_key not in counts: counts[s_key] = 0
|
| 106 |
+
|
| 107 |
+
total_lifetime = sum(counts.values())
|
| 108 |
|
| 109 |
prio_stmt = select(Ticket.priority, func.count(Ticket.id)).where(Ticket.deleted_at.is_(None))
|
| 110 |
if not is_global: prio_stmt = prio_stmt.where(Ticket.workspace_id == target_ws)
|
|
|
|
| 223 |
|
| 224 |
# 5. Final Sanitization (Nexus Privacy Layer)
|
| 225 |
response = {
|
| 226 |
+
"total_tickets": total_lifetime,
|
| 227 |
+
"total_30d": total_30d,
|
| 228 |
"by_status": counts,
|
| 229 |
"by_priority": prio_counts,
|
| 230 |
"by_category": cat_counts,
|
frontend/apps/customer/src/components/Dashboard.tsx
CHANGED
|
@@ -159,9 +159,24 @@ export const Dashboard: React.FC<DashboardProps> = ({ setActive, setSelectedTick
|
|
| 159 |
{/* Performance Metrics Dashboard */}
|
| 160 |
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: 20, flex: "1 1 500px", position: 'relative', zIndex: 2 }}>
|
| 161 |
{[
|
| 162 |
-
{
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
].map(s => (
|
| 166 |
<div key={s.label} className="glass-card" style={{
|
| 167 |
background: "rgba(255,255,255,0.08)",
|
|
|
|
| 159 |
{/* Performance Metrics Dashboard */}
|
| 160 |
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: 20, flex: "1 1 500px", position: 'relative', zIndex: 2 }}>
|
| 161 |
{[
|
| 162 |
+
{
|
| 163 |
+
label: "TOTAL TICKETS",
|
| 164 |
+
value: ticketsLoading ? <Skeleton width={60} height={32} /> : tickets.length,
|
| 165 |
+
sub: "SUBMITTED TICKETS",
|
| 166 |
+
icon: <TrendingUp size={18} />
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
label: "ACTIVE TICKETS",
|
| 170 |
+
value: ticketsLoading ? <Skeleton width={60} height={32} /> : activeTickets.length,
|
| 171 |
+
sub: "OPEN REQUESTS",
|
| 172 |
+
icon: <Zap size={18} />
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
label: "RESOLVED TICKETS",
|
| 176 |
+
value: ticketsLoading ? <Skeleton width={60} height={32} /> : resolvedCount,
|
| 177 |
+
sub: "CLOSED SUCCESSFULLY",
|
| 178 |
+
icon: <CheckCircle size={18} />
|
| 179 |
+
}
|
| 180 |
].map(s => (
|
| 181 |
<div key={s.label} className="glass-card" style={{
|
| 182 |
background: "rgba(255,255,255,0.08)",
|