File size: 2,885 Bytes
f1c0213
 
 
 
 
 
158a3ca
f1c0213
 
46d886d
 
 
f1c0213
 
 
 
18b7fec
 
 
 
 
 
 
 
f1c0213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18b7fec
 
 
f1c0213
 
 
3d69445
 
 
f1c0213
 
3d69445
f1c0213
 
3d69445
 
 
 
f1c0213
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import streamlit as st
from datetime import datetime
from get_next_standup_taker import get_next_standup_taker, team_members
from datasets import load_dataset, load_metric

# Initialize or load dataset
dataset_repo_id = "BulatF/standup_taker_dataset"
dataset = load_dataset(dataset_repo_id, split='train', streaming=True)

# Create an iterator from the dataset
dataset_iter = iter(dataset)

# Initialize login state
if 'logged_in' not in st.session_state:
    st.session_state.logged_in = False

# Initialize last_entry in session_state
if 'last_entry' not in st.session_state:
    try:
        st.session_state.last_entry = next(dataset_iter)
    except StopIteration:
        st.session_state.last_entry = {'standup_taker': 'Yiannis', 'date': '2023-01-01'}


# Login Screen
if not st.session_state.logged_in:
    st.title("Login to Stand-Up Taker App")
    username = st.text_input("Username:")
    password = st.text_input("Password:", type="password")
    
    if st.button("Login"):
        if username == "analytics" and password == "try_me_123!":
            st.session_state.logged_in = True
            st.experimental_rerun()  # Rerun the app to redirect to the main app
        else:
            st.warning("Invalid username or password")

# Main App
if st.session_state.logged_in:
    st.title("Stand-Up Taker App")

    last_standup_taker = st.session_state.last_entry['standup_taker']
    last_date = st.session_state.last_entry['date']
    
    # Button to check today's stand-up taker
    if st.button("Who is taking the stand-up today?"):
        next_taker, next_date = get_next_standup_taker(last_standup_taker, last_date)
        if isinstance(next_taker, str):
            st.write(f"The person taking the stand-up today is **{next_taker}**.")
        
        # Update dataset with new standup taker and date
        new_entry = {
            'standup_taker': next_taker,
            'date': datetime.now().strftime("%Y-%m-%d")
        }
    else:
        st.write(next_taker)
        
    # Initialize state for text field
    if 'forced_taker' not in st.session_state:
        st.session_state.forced_taker = ""
    
    # Field and button to force a specific person for the stand-up
    st.session_state.forced_taker = st.text_input("Force a specific person to take the stand-up:", st.session_state.forced_taker)
    
    if st.button("Force Stand-Up"):
        if st.session_state.forced_taker in team_members:
            # Update dataset with forced standup taker and date
            dataset = dataset.add_item({
                'standup_taker': st.session_state.forced_taker,
                'date': datetime.now().strftime("%Y-%m-%d")
            })
            
            st.write(f"The stand-up taker has been forced to **{st.session_state.forced_taker}**.")
        else:
            st.write("Invalid name. Please enter a valid team member name.")