Jon Solow
commited on
Commit
·
83551c4
1
Parent(s):
54d6a92
Add top players page
Browse files- src/format_player_html.py +21 -0
- src/pages/12_Top_Players.py +9 -3
src/format_player_html.py
CHANGED
|
@@ -32,6 +32,27 @@ def get_roster_html_str(
|
|
| 32 |
return roster_str
|
| 33 |
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def get_player_html_str(
|
| 36 |
player_opt: PlayerOption, player_stats: dict[str, float], player_score: float, multiplier: int
|
| 37 |
) -> str:
|
|
|
|
| 32 |
return roster_str
|
| 33 |
|
| 34 |
|
| 35 |
+
def get_all_position_week_html_str(week: int, player_option_list: list[PlayerOption]) -> str:
|
| 36 |
+
player_opts_with_stats = []
|
| 37 |
+
for player in player_option_list:
|
| 38 |
+
player_stats = get_stats_map().get(week, {}).get(player.gsis_id, {})
|
| 39 |
+
player_score = get_scores_map().get(week, {}).get(player.gsis_id, 0.0)
|
| 40 |
+
player_opts_with_stats.append((player, player_stats, player_score))
|
| 41 |
+
|
| 42 |
+
players_str = ""
|
| 43 |
+
player_limit = 24
|
| 44 |
+
for player, player_stats, player_score in sorted(player_opts_with_stats, key=lambda x: x[2], reverse=True)[
|
| 45 |
+
:player_limit
|
| 46 |
+
]:
|
| 47 |
+
player_multiplier = 1
|
| 48 |
+
if player_stats:
|
| 49 |
+
players_str += get_player_html_str(player, player_stats, player_score, player_multiplier)
|
| 50 |
+
roster_str = f"""<div className='user__roster'>
|
| 51 |
+
{players_str}
|
| 52 |
+
</div>"""
|
| 53 |
+
return roster_str
|
| 54 |
+
|
| 55 |
+
|
| 56 |
def get_player_html_str(
|
| 57 |
player_opt: PlayerOption, player_stats: dict[str, float], player_score: float, multiplier: int
|
| 58 |
) -> str:
|
src/pages/12_Top_Players.py
CHANGED
|
@@ -3,7 +3,8 @@ import streamlit as st
|
|
| 3 |
from config import DEFAULT_ICON
|
| 4 |
from shared_page import common_page_config
|
| 5 |
|
| 6 |
-
from load_options import
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def get_page():
|
|
@@ -12,8 +13,13 @@ def get_page():
|
|
| 12 |
common_page_config()
|
| 13 |
st.title(page_title)
|
| 14 |
|
| 15 |
-
all_options =
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
if __name__ == "__main__":
|
|
|
|
| 3 |
from config import DEFAULT_ICON
|
| 4 |
from shared_page import common_page_config
|
| 5 |
|
| 6 |
+
from load_options import load_options
|
| 7 |
+
from format_player_html import get_all_position_week_html_str
|
| 8 |
|
| 9 |
|
| 10 |
def get_page():
|
|
|
|
| 13 |
common_page_config()
|
| 14 |
st.title(page_title)
|
| 15 |
|
| 16 |
+
all_options = load_options()
|
| 17 |
+
|
| 18 |
+
week = st.selectbox("Select Week", [1, 2, 3, 4])
|
| 19 |
+
for pos in ["QB", "RB", "WR", "TE", "K", "DEF"]:
|
| 20 |
+
st.header(pos)
|
| 21 |
+
week_pos_list = all_options[pos][week]
|
| 22 |
+
st.markdown(get_all_position_week_html_str(week, week_pos_list), unsafe_allow_html=True)
|
| 23 |
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|