diff --git a/backend_api_python/app/routes/dashboard.py b/backend_api_python/app/routes/dashboard.py index 3150df7..003f2ca 100644 --- a/backend_api_python/app/routes/dashboard.py +++ b/backend_api_python/app/routes/dashboard.py @@ -354,8 +354,16 @@ def summary(): """, (user_id,) ) - recent_trades = cur.fetchall() or [] + recent_trades_raw = cur.fetchall() or [] cur.close() + + # Convert datetime to timestamp for frontend compatibility + recent_trades = [] + for t in recent_trades_raw: + trade = dict(t) + if trade.get('created_at') and hasattr(trade['created_at'], 'timestamp'): + trade['created_at'] = int(trade['created_at'].timestamp()) + recent_trades.append(trade) # Compute performance statistics perf_stats = _compute_performance_stats(recent_trades) diff --git a/quantdinger_vue/src/views/dashboard/index.vue b/quantdinger_vue/src/views/dashboard/index.vue index b81f02e..d30fbfb 100644 --- a/quantdinger_vue/src/views/dashboard/index.vue +++ b/quantdinger_vue/src/views/dashboard/index.vue @@ -992,12 +992,20 @@ export default { formatTime (timestamp) { if (!timestamp) return '-' try { - const raw = typeof timestamp === 'string' ? parseInt(timestamp, 10) : Number(timestamp) - if (!raw || Number.isNaN(raw)) return '-' - const ms = raw < 1e12 ? raw * 1000 : raw - const d = new Date(ms) - if (isNaN(d.getTime())) return '-' - return d.toLocaleString() + let date + // Handle ISO 8601 date strings (e.g., "2024-01-17T01:58:10.000Z") + if (typeof timestamp === 'string' && timestamp.includes('-') && timestamp.includes(':')) { + date = new Date(timestamp) + } else if (typeof timestamp === 'number' || (typeof timestamp === 'string' && /^\d+$/.test(timestamp))) { + // Handle numeric timestamps (seconds or milliseconds) + const numTimestamp = typeof timestamp === 'string' ? parseInt(timestamp, 10) : timestamp + const ms = numTimestamp < 1e12 ? numTimestamp * 1000 : numTimestamp + date = new Date(ms) + } else { + return '-' + } + if (isNaN(date.getTime())) return '-' + return date.toLocaleString() } catch (e) { return '-' }