File size: 1,180 Bytes
8cbbcd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import datetime
import streamlit as st

from config import DEFAULT_ICON
from shared_page import common_page_config

from queries.footballguys.constants import YEAR
from queries.nflverse.github_data import get_snap_counts
from streamlit_filter import filter_dataframe


@st.cache_data(ttl=60 * 60 * 24)
def load_data():
    data = get_snap_counts(YEAR)
    data_load_time_str = datetime.datetime.utcnow().strftime("%m/%d/%Y %I:%M %p")
    return data, data_load_time_str


def get_page():
    page_title = f"Player Redzone Opportunities - {YEAR}"
    st.set_page_config(page_title=page_title, page_icon=DEFAULT_ICON, layout="wide")
    common_page_config()
    st.title(page_title)
    if st.button("Refresh Data"):
        st.cache_data.clear()
    data, data_load_time_str = load_data()
    st.write(f"Data loaded as of: {data_load_time_str} UTC")

    with st.container():
        filtered_data = filter_dataframe(data)
        st.dataframe(
            filtered_data,
            hide_index=True,
            # height=35 * (len(filtered_data) + 1) + 12,
            use_container_width=False,
            column_config={},
        )


if __name__ == "__main__":
    get_page()