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