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}.")