GenAITeamInfobell
commited on
Commit
•
d4040f5
1
Parent(s):
140daf4
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,10 @@ import random
|
|
3 |
import json
|
4 |
import os
|
5 |
from datetime import datetime
|
6 |
-
import schedule
|
7 |
-
import time
|
8 |
-
import threading
|
9 |
|
10 |
-
#
|
11 |
-
USERNAME =
|
12 |
-
PASSWORD =
|
13 |
|
14 |
# List of team members
|
15 |
team_members = [
|
@@ -30,6 +27,7 @@ if not os.path.exists(HISTORY_FILE):
|
|
30 |
with open(HISTORY_FILE, 'w') as f:
|
31 |
json.dump([], f)
|
32 |
|
|
|
33 |
def select_members(members, last_selected, num_to_select=2):
|
34 |
available_members = [member for member in members if member not in last_selected]
|
35 |
if len(available_members) < num_to_select:
|
@@ -39,6 +37,7 @@ def select_members(members, last_selected, num_to_select=2):
|
|
39 |
last_selected.extend(selected_members)
|
40 |
return selected_members
|
41 |
|
|
|
42 |
def save_history(selection):
|
43 |
with open(HISTORY_FILE, 'r') as f:
|
44 |
history = json.load(f)
|
@@ -46,30 +45,15 @@ def save_history(selection):
|
|
46 |
with open(HISTORY_FILE, 'w') as f:
|
47 |
json.dump(history, f)
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
def authenticate(username, password):
|
50 |
return username == USERNAME and password == PASSWORD
|
51 |
|
52 |
-
def run_daily_selection():
|
53 |
-
last_selected = []
|
54 |
-
try:
|
55 |
-
selected_members = select_members(team_members, last_selected)
|
56 |
-
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
57 |
-
save_history({"run": "Scheduled", "members": selected_members, "timestamp": timestamp})
|
58 |
-
print(f"Scheduled Run - Selected members: {', '.join(selected_members)} at {timestamp}")
|
59 |
-
except ValueError as e:
|
60 |
-
print(f"Error during scheduled run: {e}")
|
61 |
-
|
62 |
-
def start_scheduler():
|
63 |
-
schedule.every().day.at("09:30").do(run_daily_selection) # 09:30 UTC is 3:00 PM IST
|
64 |
-
|
65 |
-
while True:
|
66 |
-
schedule.run_pending()
|
67 |
-
time.sleep(1)
|
68 |
-
|
69 |
-
# Start the scheduler in a separate thread
|
70 |
-
scheduler_thread = threading.Thread(target=start_scheduler, daemon=True)
|
71 |
-
scheduler_thread.start()
|
72 |
-
|
73 |
# Streamlit UI
|
74 |
st.title("AI Learning Presentation - Team Member Selection")
|
75 |
|
@@ -105,4 +89,10 @@ else:
|
|
105 |
history = json.load(f)
|
106 |
st.write("Selection History:")
|
107 |
for entry in history:
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import json
|
4 |
import os
|
5 |
from datetime import datetime
|
|
|
|
|
|
|
6 |
|
7 |
+
# Configuration for authentication
|
8 |
+
USERNAME = "admin"
|
9 |
+
PASSWORD = "password123"
|
10 |
|
11 |
# List of team members
|
12 |
team_members = [
|
|
|
27 |
with open(HISTORY_FILE, 'w') as f:
|
28 |
json.dump([], f)
|
29 |
|
30 |
+
# Function to select random team members
|
31 |
def select_members(members, last_selected, num_to_select=2):
|
32 |
available_members = [member for member in members if member not in last_selected]
|
33 |
if len(available_members) < num_to_select:
|
|
|
37 |
last_selected.extend(selected_members)
|
38 |
return selected_members
|
39 |
|
40 |
+
# Function to save history
|
41 |
def save_history(selection):
|
42 |
with open(HISTORY_FILE, 'r') as f:
|
43 |
history = json.load(f)
|
|
|
45 |
with open(HISTORY_FILE, 'w') as f:
|
46 |
json.dump(history, f)
|
47 |
|
48 |
+
# Function to clear history
|
49 |
+
def clear_history():
|
50 |
+
with open(HISTORY_FILE, 'w') as f:
|
51 |
+
json.dump([], f)
|
52 |
+
|
53 |
+
# Authentication
|
54 |
def authenticate(username, password):
|
55 |
return username == USERNAME and password == PASSWORD
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
# Streamlit UI
|
58 |
st.title("AI Learning Presentation - Team Member Selection")
|
59 |
|
|
|
89 |
history = json.load(f)
|
90 |
st.write("Selection History:")
|
91 |
for entry in history:
|
92 |
+
# Handle the absence of 'timestamp' in older entries
|
93 |
+
timestamp = entry.get('timestamp', 'N/A')
|
94 |
+
st.write(f"Run {entry['run']} - Selected members: {', '.join(entry['members'])} at {timestamp}")
|
95 |
+
|
96 |
+
if st.button("Clear History"):
|
97 |
+
clear_history()
|
98 |
+
st.success("History cleared successfully!")
|