-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
59 lines (48 loc) · 1.83 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import datetime
import os
import streamlit as st
from data_utils import get_date_range, get_conversation_stats
from search import show_search
from utils import get_session
if os.environ['HOME'] != '/home/udf':
st.set_page_config(layout="wide", page_title="Sales Analysis with Cortex and Symbl.ai")
def show_top_controls(_session):
st.title("Sales Analysis with Cortex and Symbl.ai")
date_range = get_date_range(_session)
if date_range.empty:
_to = datetime.datetime.now()
_from = _to - datetime.timedelta(days=14)
else:
_from = date_range["MIN_DATE"][0]
_to = date_range["MAX_DATE"][0]
st.session_state.min_date = _from
st.session_state.max_date = _to
with st.container():
_, __, ___, col1, col2 = st.columns([0.4, 0.1, 0.1, 0.2, 0.2])
with _:
show_search()
with __:
st.write("")
with ___:
st.write("")
with col1:
from_date = st.date_input("From", _from, min_value=_from, max_value=_to, key="from_date")
with col2:
to_date = st.date_input("To", _to, min_value=_from, max_value=_to, key="to_date")
def display(snowflake_session):
# Display the date selector
show_top_controls(snowflake_session)
session = get_session()
conversation_stats = get_conversation_stats(session).iloc[0]
if int(conversation_stats['COUNT']) <= 0:
st.markdown("***No conversations found in database.***")
if os.environ['HOME'] != '/home/udf':
display(session)
pg = st.navigation([
st.Page("pages/overview.py", title="Overview", default=True),
st.Page("pages/reps.py", title="Sales Reps"),
st.Page("pages/accounts.py", title="Accounts"),
st.Page("pages/chat_bot.py", title="Chat")])
pg.run()
else:
st.markdown("### Select the 👈 option to see the analysis.")