Jon Solow
commited on
Commit
·
9d8e6a4
1
Parent(s):
80cfc94
Allow scoreboard for not logged in and stub out where rosters will go
Browse files- src/data_storage.py +10 -2
- src/pages/11_Scoreboard.py +35 -8
src/data_storage.py
CHANGED
@@ -123,8 +123,16 @@ def drop_tables():
|
|
123 |
cur.execute("DROP TABLE tokens")
|
124 |
|
125 |
|
126 |
-
def get_all_users():
|
|
|
127 |
with get_db_connection() as con:
|
128 |
cur = con.cursor()
|
129 |
-
all_users = cur.execute("select
|
130 |
return all_users
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
cur.execute("DROP TABLE tokens")
|
124 |
|
125 |
|
126 |
+
def get_all_users(columns_included: list[str] = ["user_id", "name", "email"]):
|
127 |
+
columns_as_str = ",".join(columns_included)
|
128 |
with get_db_connection() as con:
|
129 |
cur = con.cursor()
|
130 |
+
all_users = cur.execute(f"select {columns_as_str} from users").fetchall()
|
131 |
return all_users
|
132 |
+
|
133 |
+
|
134 |
+
def get_all_rosters():
|
135 |
+
with get_db_connection() as con:
|
136 |
+
cur = con.cursor()
|
137 |
+
all_rosters = cur.execute("select * from user_rosters").fetchall()
|
138 |
+
return all_rosters
|
src/pages/11_Scoreboard.py
CHANGED
@@ -2,27 +2,54 @@ import pandas as pd
|
|
2 |
import streamlit as st
|
3 |
|
4 |
from config import DEFAULT_ICON
|
5 |
-
from login import check_password
|
6 |
from shared_page import common_page_config
|
7 |
|
8 |
from data_storage import get_all_users
|
|
|
9 |
|
10 |
|
11 |
-
def
|
12 |
-
|
13 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def get_page():
|
17 |
page_title = "Pool Scoreboard"
|
18 |
st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
|
19 |
common_page_config()
|
20 |
-
if not check_password():
|
21 |
-
st.write("Sorry, you must be logged in first to play")
|
22 |
-
st.stop()
|
23 |
|
24 |
st.title(page_title)
|
25 |
-
|
|
|
26 |
|
27 |
|
28 |
if __name__ == "__main__":
|
|
|
2 |
import streamlit as st
|
3 |
|
4 |
from config import DEFAULT_ICON
|
|
|
5 |
from shared_page import common_page_config
|
6 |
|
7 |
from data_storage import get_all_users
|
8 |
+
from domain.playoffs import CURRENT_PLAYOFF_WEEK, PLAYOFF_WEEK_TO_NAME
|
9 |
|
10 |
|
11 |
+
def display_user_names():
|
12 |
+
users_names = get_users_df()["name"]
|
13 |
+
st.markdown("<h2>Users</h2>", unsafe_allow_html=True)
|
14 |
+
st.dataframe(users_names, hide_index=True)
|
15 |
+
|
16 |
+
|
17 |
+
def get_users_df():
|
18 |
+
columns = ["user_id", "name"]
|
19 |
+
all_users = pd.DataFrame(get_all_users(columns_included=columns), columns=columns)
|
20 |
+
return all_users
|
21 |
+
|
22 |
+
|
23 |
+
def get_masked_rosters(week: int):
|
24 |
+
# TODO
|
25 |
+
return pd.DataFrame()
|
26 |
+
|
27 |
+
|
28 |
+
def display_rosters():
|
29 |
+
st.markdown("<h2>Rosters</h2>", unsafe_allow_html=True)
|
30 |
+
options = list(PLAYOFF_WEEK_TO_NAME.keys())
|
31 |
+
default_selection = options.index(CURRENT_PLAYOFF_WEEK)
|
32 |
+
week_selected = st.selectbox(
|
33 |
+
"Week",
|
34 |
+
options=options,
|
35 |
+
index=default_selection,
|
36 |
+
key="roster_week_select",
|
37 |
+
format_func=lambda x: PLAYOFF_WEEK_TO_NAME[x],
|
38 |
+
)
|
39 |
+
|
40 |
+
rosters = get_masked_rosters(week_selected)
|
41 |
+
if len(rosters):
|
42 |
+
st.write(rosters)
|
43 |
|
44 |
|
45 |
def get_page():
|
46 |
page_title = "Pool Scoreboard"
|
47 |
st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
|
48 |
common_page_config()
|
|
|
|
|
|
|
49 |
|
50 |
st.title(page_title)
|
51 |
+
display_user_names()
|
52 |
+
display_rosters()
|
53 |
|
54 |
|
55 |
if __name__ == "__main__":
|