James McCool
commited on
Commit
·
9b97a5a
1
Parent(s):
c08b1bb
moving the slate designation out of the database_queries
Browse files- app.py +50 -0
- database.py +3 -2
app.py
CHANGED
|
@@ -120,6 +120,56 @@ st.markdown("""
|
|
| 120 |
|
| 121 |
</style>""", unsafe_allow_html=True)
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
# Memory optimization helper functions
|
| 124 |
def chunk_name_matching(portfolio_names, csv_names, chunk_size=1000):
|
| 125 |
"""Process name matching in chunks to reduce memory usage"""
|
|
|
|
| 120 |
|
| 121 |
</style>""", unsafe_allow_html=True)
|
| 122 |
|
| 123 |
+
def grab_nfl_reg_salaries():
|
| 124 |
+
collection = salaries_db["NFL_reg_player_info"]
|
| 125 |
+
today_int = int(datetime.now().strftime("%Y%m%d"))
|
| 126 |
+
records = list(collection.find({'date': {'$gte': today_int}}))
|
| 127 |
+
return pd.DataFrame(records)
|
| 128 |
+
|
| 129 |
+
def define_dk_nfl_showdown_slates():
|
| 130 |
+
collection = nfl_db["DK_SD_NFL_ROO"]
|
| 131 |
+
cursor = collection.find()
|
| 132 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 133 |
+
unique_slates = raw_display['slate'].unique()
|
| 134 |
+
|
| 135 |
+
slate_names = []
|
| 136 |
+
|
| 137 |
+
for slate in unique_slates:
|
| 138 |
+
slate_data = raw_display[raw_display['slate'] == slate]
|
| 139 |
+
slate_name = slate_data.iloc[0]['Team'] + ' vs. ' + slate_data.iloc[0]['Opp']
|
| 140 |
+
slate_names.append(slate_name)
|
| 141 |
+
|
| 142 |
+
slate_name_lookup = dict(zip(slate_names, unique_slates))
|
| 143 |
+
return slate_names, slate_name_lookup
|
| 144 |
+
|
| 145 |
+
def define_fd_nfl_showdown_slates():
|
| 146 |
+
collection = nfl_db["FD_SD_NFL_ROO"]
|
| 147 |
+
cursor = collection.find()
|
| 148 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 149 |
+
unique_slates = raw_display['slate'].unique()
|
| 150 |
+
|
| 151 |
+
slate_names = []
|
| 152 |
+
|
| 153 |
+
for slate in unique_slates:
|
| 154 |
+
slate_data = raw_display[raw_display['slate'] == slate]
|
| 155 |
+
slate_name = slate_data.iloc[0]['Team'] + ' vs. ' + slate_data.iloc[0]['Opp']
|
| 156 |
+
slate_names.append(slate_name)
|
| 157 |
+
|
| 158 |
+
slate_name_lookup = dict(zip(slate_names, unique_slates))
|
| 159 |
+
return slate_names, slate_name_lookup
|
| 160 |
+
|
| 161 |
+
try:
|
| 162 |
+
nfl_slate_names_dk, nfl_slate_name_lookup_dk = define_dk_nfl_showdown_slates()
|
| 163 |
+
except:
|
| 164 |
+
nfl_slate_names_dk = []
|
| 165 |
+
nfl_slate_name_lookup_dk = {}
|
| 166 |
+
|
| 167 |
+
try:
|
| 168 |
+
nfl_slate_names_fd, nfl_slate_name_lookup_fd = define_fd_nfl_showdown_slates()
|
| 169 |
+
except:
|
| 170 |
+
nfl_slate_names_fd = []
|
| 171 |
+
nfl_slate_name_lookup_fd = {}
|
| 172 |
+
|
| 173 |
# Memory optimization helper functions
|
| 174 |
def chunk_name_matching(portfolio_names, csv_names, chunk_size=1000):
|
| 175 |
"""Process name matching in chunks to reduce memory usage"""
|
database.py
CHANGED
|
@@ -10,7 +10,8 @@ def init_conn():
|
|
| 10 |
uri = st.secrets['mongo_uri']
|
| 11 |
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
|
| 12 |
nfl_db = client["NFL_Database"]
|
|
|
|
| 13 |
|
| 14 |
-
return nfl_db
|
| 15 |
|
| 16 |
-
nfl_db = init_conn()
|
|
|
|
| 10 |
uri = st.secrets['mongo_uri']
|
| 11 |
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
|
| 12 |
nfl_db = client["NFL_Database"]
|
| 13 |
+
salaries_db = client['Contest_Information']
|
| 14 |
|
| 15 |
+
return nfl_db, salaries_db
|
| 16 |
|
| 17 |
+
nfl_db, salaries_db = init_conn()
|