James McCool commited on
Commit
237dfa0
·
1 Parent(s): 2e150af

Modify init_DK_lineups and init_FD_lineups to support Regular and Showdown slate types

Browse files

- Add 'type' parameter to differentiate between Regular and Showdown slates
- Update database collection selection based on slate type
- Modify tab2 to include slate type selection for DraftKings and FanDuel
- Remove hardcoded lineup initializations at the start of the script

Files changed (1) hide show
  1. app.py +36 -15
app.py CHANGED
@@ -50,14 +50,20 @@ def init_baselines():
50
  return roo_data, sd_roo_data, timestamp
51
 
52
  @st.cache_data(ttl = 60)
53
- def init_DK_lineups():
54
 
55
- collection = db['PGA_DK_Seed_Frame_Name_Map']
 
 
 
56
  cursor = collection.find()
57
  raw_data = pd.DataFrame(list(cursor))
58
  names_dict = dict(zip(raw_data['key'], raw_data['value']))
59
-
60
- collection = db["PGA_DK_Seed_Frame"]
 
 
 
61
  cursor = collection.find().limit(10000)
62
 
63
  raw_display = pd.DataFrame(list(cursor))
@@ -70,14 +76,20 @@ def init_DK_lineups():
70
  return DK_seed
71
 
72
  @st.cache_data(ttl = 60)
73
- def init_FD_lineups():
74
 
75
- collection = db['PGA_DK_Seed_Frame_Name_Map']
 
 
 
76
  cursor = collection.find()
77
  raw_data = pd.DataFrame(list(cursor))
78
  names_dict = dict(zip(raw_data['key'], raw_data['value']))
79
-
80
- collection = db["PGA_DK_Seed_Frame"]
 
 
 
81
  cursor = collection.find().limit(10000)
82
 
83
  raw_display = pd.DataFrame(list(cursor))
@@ -98,8 +110,6 @@ def convert_df(array):
98
  return array.to_csv().encode('utf-8')
99
 
100
  roo_data, sd_roo_data, timestamp = init_baselines()
101
- dk_lineups = init_DK_lineups()
102
- fd_lineups = init_FD_lineups()
103
  hold_display = roo_data
104
  lineup_display = []
105
  check_list = []
@@ -115,8 +125,8 @@ with tab1:
115
  # i.e. clear values from both square and cube
116
  st.cache_data.clear()
117
  roo_data, sd_roo_data, timestamp = init_baselines()
118
- dk_lineups = init_DK_lineups()
119
- fd_lineups = init_FD_lineups()
120
  hold_display = roo_data
121
  for key in st.session_state.keys():
122
  del st.session_state[key]
@@ -169,14 +179,25 @@ with tab2:
169
  st.cache_data.clear()
170
  roo_data, sd_roo_data, timestamp = init_baselines()
171
  hold_display = roo_data
172
- dk_lineups = init_DK_lineups()
173
- fd_lineups = init_FD_lineups()
174
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
175
  for key in st.session_state.keys():
176
  del st.session_state[key]
177
 
178
- slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Just the Main Slate'))
 
179
  site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'))
 
 
 
 
 
 
 
 
 
 
180
  lineup_num_var = st.number_input("How many lineups do you want to display?", min_value=1, max_value=1000, value=150, step=1)
181
 
182
  if site_var1 == 'Draftkings':
 
50
  return roo_data, sd_roo_data, timestamp
51
 
52
  @st.cache_data(ttl = 60)
53
+ def init_DK_lineups(type):
54
 
55
+ if type == 'Regular':
56
+ collection = db['PGA_DK_Seed_Frame_Name_Map']
57
+ elif type == 'Showdown':
58
+ collection = db['PGA_DK_SD_Seed_Frame_Name_Map']
59
  cursor = collection.find()
60
  raw_data = pd.DataFrame(list(cursor))
61
  names_dict = dict(zip(raw_data['key'], raw_data['value']))
62
+
63
+ if type == 'Regular':
64
+ collection = db["PGA_DK_Seed_Frame"]
65
+ elif type == 'Showdown':
66
+ collection = db["PGA_DK_SD_Seed_Frame"]
67
  cursor = collection.find().limit(10000)
68
 
69
  raw_display = pd.DataFrame(list(cursor))
 
76
  return DK_seed
77
 
78
  @st.cache_data(ttl = 60)
79
+ def init_FD_lineups(type):
80
 
81
+ if type == 'Regular':
82
+ collection = db['PGA_DK_Seed_Frame_Name_Map']
83
+ elif type == 'Showdown':
84
+ collection = db['PGA_DK_SD_Seed_Frame_Name_Map']
85
  cursor = collection.find()
86
  raw_data = pd.DataFrame(list(cursor))
87
  names_dict = dict(zip(raw_data['key'], raw_data['value']))
88
+
89
+ if type == 'Regular':
90
+ collection = db["PGA_DK_Seed_Frame"]
91
+ elif type == 'Showdown':
92
+ collection = db["PGA_DK_SD_Seed_Frame"]
93
  cursor = collection.find().limit(10000)
94
 
95
  raw_display = pd.DataFrame(list(cursor))
 
110
  return array.to_csv().encode('utf-8')
111
 
112
  roo_data, sd_roo_data, timestamp = init_baselines()
 
 
113
  hold_display = roo_data
114
  lineup_display = []
115
  check_list = []
 
125
  # i.e. clear values from both square and cube
126
  st.cache_data.clear()
127
  roo_data, sd_roo_data, timestamp = init_baselines()
128
+ dk_lineups = init_DK_lineups('Regular')
129
+ fd_lineups = init_FD_lineups('Regular')
130
  hold_display = roo_data
131
  for key in st.session_state.keys():
132
  del st.session_state[key]
 
179
  st.cache_data.clear()
180
  roo_data, sd_roo_data, timestamp = init_baselines()
181
  hold_display = roo_data
182
+ dk_lineups = init_DK_lineups('Regular')
183
+ fd_lineups = init_FD_lineups('Regular')
184
  t_stamp = f"Last Update: " + str(timestamp) + f" CST"
185
  for key in st.session_state.keys():
186
  del st.session_state[key]
187
 
188
+ slate_var1 = st.radio("Which data are you loading?", ('Regular', 'Showdown'))
189
+
190
  site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'))
191
+ if slate_var1 == 'Regular':
192
+ if site_var1 == 'Draftkings':
193
+ dk_lineups = init_DK_lineups('Regular')
194
+ elif site_var1 == 'Fanduel':
195
+ fd_lineups = init_FD_lineups('Regular')
196
+ elif slate_var1 == 'Showdown':
197
+ if site_var1 == 'Draftkings':
198
+ dk_lineups = init_DK_lineups('Showdown')
199
+ elif site_var1 == 'Fanduel':
200
+ fd_lineups = init_FD_lineups('Showdown')
201
  lineup_num_var = st.number_input("How many lineups do you want to display?", min_value=1, max_value=1000, value=150, step=1)
202
 
203
  if site_var1 == 'Draftkings':