File size: 3,449 Bytes
f1c0213
 
7f437d4
f1c0213
 
 
 
158a3ca
f1c0213
 
46d886d
 
 
f1c0213
3a3b0c3
f1c0213
 
18b7fec
 
 
 
 
 
 
0f79e8b
 
 
18b7fec
73c760a
 
 
 
7f437d4
 
 
 
f1c0213
 
 
 
 
 
 
7f437d4
f1c0213
73c760a
f1c0213
 
 
 
 
 
18b7fec
 
 
f1c0213
 
3d69445
f050396
73c760a
f050396
 
 
 
 
 
3d69445
f050396
 
 
f72c5a3
f050396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import streamlit as st
from datetime import datetime
import os
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'}

# Initialize next_taker in session_state
if 'next_taker' not in st.session_state:
    st.session_state.next_taker = "Not decided yet"

# Initialize standup_history in session_state
if 'standup_history' not in st.session_state:
    st.session_state.standup_history = []

# Fetch login and password from environment variables
username_secret = os.environ.get("login")
password_secret = os.environ.get("password")

# 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 == username_secret and password == password_secret:
            st.session_state.logged_in = True
            st.experimental_rerun()
        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']
    
    if st.button("Who is taking the stand-up today?"):
        next_taker, next_date = get_next_standup_taker(last_standup_taker, last_date)
        st.session_state.next_taker = next_taker
        
        # Update standup_history list
        new_entry = {
            'standup_taker': next_taker,
            'date': datetime.now().strftime("%Y-%m-%d")
        }
        st.session_state.standup_history.append(new_entry)
        
        st.write(f"The person taking the stand-up today is **{next_taker}**.")
    else:
        st.write(st.session_state.next_taker)
        
    if 'forced_taker' not in st.session_state:
        st.session_state.forced_taker = ""
    
    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"):
        current_weekday = datetime.now().strftime("%A")
        if current_weekday in ["Tuesday", "Thursday"]:
            if st.session_state.forced_taker in team_members:
                new_entry = {
                    'standup_taker': st.session_state.forced_taker,
                    'date': datetime.now().strftime("%Y-%m-%d")
                }
                st.session_state.standup_history.append(new_entry)
                
                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.")
        else:
            st.write(f"Stand-up taker can only be forced on Tuesday and Thursday. Today is {current_weekday}.")