diff --git a/backend/app.py b/backend/app.py index 3525c6b..fcef01c 100644 --- a/backend/app.py +++ b/backend/app.py @@ -313,6 +313,11 @@ def get_all_data(): if messages_missing_parent > 0: logger.warning(f"Found {messages_missing_parent} messages that could not be linked to a conversation") + # Log warning if any messages ended up without a Timestamp after enrichment + msg_no_timestamp = sum(1 for m in enriched_messages if not m.get("Timestamp")) + if msg_no_timestamp: + logger.warning(f"Messages missing Timestamp after enrichment: {msg_no_timestamp} / {len(enriched_messages)}") + # Log warning if messages are missing Assistant_ID msg_has_assistant_id = sum(1 for msg in enriched_messages if msg.get("Assistant_ID")) msg_no_assistant_id = sum(1 for msg in enriched_messages if not msg.get("Assistant_ID")) diff --git a/frontend/src/components/Dashboard.jsx b/frontend/src/components/Dashboard.jsx index 71bb35d..7c4be5c 100644 --- a/frontend/src/components/Dashboard.jsx +++ b/frontend/src/components/Dashboard.jsx @@ -99,22 +99,26 @@ const Dashboard = ({ conversations, messages }) => { let matches = true; - // Date range filter - only apply if both start and end dates are set - if (filters.dateRange.start && filters.dateRange.end && conv.StartTime) { - try { - const convDate = parseISO(conv.StartTime); - if (isValid(convDate)) { - matches = matches && isWithinInterval(convDate, { - start: filters.dateRange.start, - end: filters.dateRange.end - }); - } else { - console.warn("Invalid date in conversation:", conv.StartTime); + // Date range filter - fail-closed: missing/unparseable StartTime is excluded when a range is active + if (filters.dateRange.start && filters.dateRange.end) { + if (!conv.StartTime) { + matches = false; + } else { + try { + const convDate = parseISO(conv.StartTime); + if (!isValid(convDate)) { + console.warn("Invalid date in conversation:", conv.StartTime); + matches = false; + } else { + matches = matches && isWithinInterval(convDate, { + start: filters.dateRange.start, + end: filters.dateRange.end, + }); + } + } catch (e) { + console.error("Error parsing conversation date:", e); matches = false; } - } catch (e) { - console.error("Error parsing conversation date:", e); - matches = false; } } @@ -157,22 +161,26 @@ const Dashboard = ({ conversations, messages }) => { let matches = true; - // Date range filter - only apply if both start and end dates are set - if (filters.dateRange.start && filters.dateRange.end && msg.Timestamp) { - try { - const msgDate = parseISO(msg.Timestamp); - if (isValid(msgDate)) { - matches = matches && isWithinInterval(msgDate, { - start: filters.dateRange.start, - end: filters.dateRange.end - }); - } else { - console.warn("Invalid date in message:", msg.Timestamp); + // Date range filter - fail-closed: missing/unparseable Timestamp is excluded when a range is active + if (filters.dateRange.start && filters.dateRange.end) { + if (!msg.Timestamp) { + matches = false; + } else { + try { + const msgDate = parseISO(msg.Timestamp); + if (!isValid(msgDate)) { + console.warn("Invalid date in message:", msg.Timestamp); + matches = false; + } else { + matches = matches && isWithinInterval(msgDate, { + start: filters.dateRange.start, + end: filters.dateRange.end, + }); + } + } catch (e) { + console.error("Error parsing message date:", e); matches = false; } - } catch (e) { - console.error("Error parsing message date:", e); - matches = false; } }