Commit Β·
9d8cdaa
1
Parent(s): 2e0c97a
Fixing global search
Browse files
visualization/app.py
CHANGED
|
@@ -35,7 +35,6 @@ st.set_page_config(
|
|
| 35 |
initial_sidebar_state=config['page_config']['initial_sidebar_state']
|
| 36 |
)
|
| 37 |
|
| 38 |
-
|
| 39 |
st.markdown("""
|
| 40 |
<style>
|
| 41 |
.block-container {
|
|
@@ -46,8 +45,6 @@ st.markdown("""
|
|
| 46 |
</style>
|
| 47 |
""", unsafe_allow_html=True)
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
# ββ Authentication gate βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
# render_login_page() calls st.stop() when the user is not authenticated,
|
| 53 |
# so nothing below this point executes until login succeeds.
|
|
@@ -226,7 +223,8 @@ def main():
|
|
| 226 |
render_reply_required(data_loader)
|
| 227 |
|
| 228 |
elif page == "π§ HelpScout Dashboard":
|
| 229 |
-
|
|
|
|
| 230 |
|
| 231 |
elif page == "π¬ HelpScout Analysis":
|
| 232 |
render_helpscout_analysis(helpscout_loader)
|
|
|
|
| 35 |
initial_sidebar_state=config['page_config']['initial_sidebar_state']
|
| 36 |
)
|
| 37 |
|
|
|
|
| 38 |
st.markdown("""
|
| 39 |
<style>
|
| 40 |
.block-container {
|
|
|
|
| 45 |
</style>
|
| 46 |
""", unsafe_allow_html=True)
|
| 47 |
|
|
|
|
|
|
|
| 48 |
# ββ Authentication gate βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 49 |
# render_login_page() calls st.stop() when the user is not authenticated,
|
| 50 |
# so nothing below this point executes until login succeeds.
|
|
|
|
| 223 |
render_reply_required(data_loader)
|
| 224 |
|
| 225 |
elif page == "π§ HelpScout Dashboard":
|
| 226 |
+
hs_date_range = global_filters.get('date_range') if filters_applied else None
|
| 227 |
+
render_helpscout_dashboard(helpscout_loader, date_range=hs_date_range)
|
| 228 |
|
| 229 |
elif page == "π¬ HelpScout Analysis":
|
| 230 |
render_helpscout_analysis(helpscout_loader)
|
visualization/components/dashboard.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
Main Dashboard Page
|
| 3 |
Displays overall sentiment distributions by brand and platform
|
| 4 |
"""
|
|
|
|
| 5 |
import streamlit as st
|
| 6 |
import sys
|
| 7 |
from pathlib import Path
|
|
@@ -632,6 +633,14 @@ def render_dashboard(df):
|
|
| 632 |
if hs_df is not None and not hs_df.empty:
|
| 633 |
try:
|
| 634 |
from components.helpscout_dashboard import render_helpscout_compact_summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
render_helpscout_compact_summary(hs_df)
|
| 636 |
except Exception:
|
| 637 |
pass # never break the main dashboard if helpscout module fails
|
|
|
|
| 2 |
Main Dashboard Page
|
| 3 |
Displays overall sentiment distributions by brand and platform
|
| 4 |
"""
|
| 5 |
+
import pandas as pd
|
| 6 |
import streamlit as st
|
| 7 |
import sys
|
| 8 |
from pathlib import Path
|
|
|
|
| 633 |
if hs_df is not None and not hs_df.empty:
|
| 634 |
try:
|
| 635 |
from components.helpscout_dashboard import render_helpscout_compact_summary
|
| 636 |
+
global_filters = st.session_state.get('global_filters', {})
|
| 637 |
+
filters_applied = st.session_state.get('filters_applied', False)
|
| 638 |
+
if filters_applied and global_filters.get('date_range') and "first_message_at" in hs_df.columns:
|
| 639 |
+
dr = global_filters['date_range']
|
| 640 |
+
hs_df = hs_df[
|
| 641 |
+
(hs_df["first_message_at"] >= pd.Timestamp(dr[0])) &
|
| 642 |
+
(hs_df["first_message_at"] <= pd.Timestamp(dr[1]))
|
| 643 |
+
]
|
| 644 |
render_helpscout_compact_summary(hs_df)
|
| 645 |
except Exception:
|
| 646 |
pass # never break the main dashboard if helpscout module fails
|
visualization/components/helpscout_dashboard.py
CHANGED
|
@@ -27,12 +27,13 @@ def _sentiment_score(df) -> float:
|
|
| 27 |
return float(scores.mean())
|
| 28 |
|
| 29 |
|
| 30 |
-
def render_helpscout_dashboard(data_loader):
|
| 31 |
"""
|
| 32 |
Render the full HelpScout Dashboard page.
|
| 33 |
|
| 34 |
Args:
|
| 35 |
data_loader: HelpScoutDataLoader instance
|
|
|
|
| 36 |
"""
|
| 37 |
st.title("π§ HelpScout Support Dashboard")
|
| 38 |
st.markdown("Customer support conversation analysis from HelpScout.")
|
|
@@ -42,6 +43,17 @@ def render_helpscout_dashboard(data_loader):
|
|
| 42 |
st.warning("No HelpScout data available. Please check your Snowflake connection.")
|
| 43 |
return
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
charts = HelpScoutCharts()
|
| 46 |
taxonomy = load_topic_taxonomy()
|
| 47 |
|
|
|
|
| 27 |
return float(scores.mean())
|
| 28 |
|
| 29 |
|
| 30 |
+
def render_helpscout_dashboard(data_loader, date_range=None):
|
| 31 |
"""
|
| 32 |
Render the full HelpScout Dashboard page.
|
| 33 |
|
| 34 |
Args:
|
| 35 |
data_loader: HelpScoutDataLoader instance
|
| 36 |
+
date_range: optional (start_date, end_date) tuple from global sidebar filters
|
| 37 |
"""
|
| 38 |
st.title("π§ HelpScout Support Dashboard")
|
| 39 |
st.markdown("Customer support conversation analysis from HelpScout.")
|
|
|
|
| 43 |
st.warning("No HelpScout data available. Please check your Snowflake connection.")
|
| 44 |
return
|
| 45 |
|
| 46 |
+
if date_range and len(date_range) == 2 and "first_message_at" in hs_df.columns:
|
| 47 |
+
hs_df = hs_df[
|
| 48 |
+
(hs_df["first_message_at"] >= pd.Timestamp(date_range[0])) &
|
| 49 |
+
(hs_df["first_message_at"] <= pd.Timestamp(date_range[1]))
|
| 50 |
+
]
|
| 51 |
+
if hs_df.empty:
|
| 52 |
+
st.warning("No HelpScout conversations match the selected date range.")
|
| 53 |
+
return
|
| 54 |
+
st.info(f"Showing **{len(hs_df):,}** conversations filtered by date range "
|
| 55 |
+
f"({date_range[0]} β {date_range[1]})")
|
| 56 |
+
|
| 57 |
charts = HelpScoutCharts()
|
| 58 |
taxonomy = load_topic_taxonomy()
|
| 59 |
|