James McCool commited on
Commit
bea4631
·
1 Parent(s): 37bad99

Refactor app.py: Update seed frame initialization functions to accept a load size parameter, limiting the number of records fetched from the database. This change enhances performance by allowing for more controlled data retrieval in DraftKings and FanDuel seed frame functions.

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -22,10 +22,10 @@ dk_columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', '
22
  fd_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']
23
 
24
  @st.cache_data(ttl = 60)
25
- def init_DK_seed_frames():
26
 
27
  collection = db["DK_NBA_seed_frame"]
28
- cursor = collection.find()
29
 
30
  raw_display = pd.DataFrame(list(cursor))
31
  raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
@@ -34,10 +34,10 @@ def init_DK_seed_frames():
34
  return DK_seed
35
 
36
  @st.cache_data(ttl = 60)
37
- def init_DK_secondary_seed_frames():
38
 
39
  collection = db["DK_NBA_Secondary_seed_frame"]
40
- cursor = collection.find()
41
 
42
  raw_display = pd.DataFrame(list(cursor))
43
  raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
@@ -46,10 +46,10 @@ def init_DK_secondary_seed_frames():
46
  return DK_secondary
47
 
48
  @st.cache_data(ttl = 60)
49
- def init_FD_seed_frames():
50
 
51
  collection = db["FD_NBA_seed_frame"]
52
- cursor = collection.find()
53
 
54
  raw_display = pd.DataFrame(list(cursor))
55
  raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
@@ -58,10 +58,10 @@ def init_FD_seed_frames():
58
  return FD_seed
59
 
60
  @st.cache_data(ttl = 60)
61
- def init_FD_secondary_seed_frames():
62
 
63
  collection = db["FD_NBA_Secondary_seed_frame"]
64
- cursor = collection.find()
65
 
66
  raw_display = pd.DataFrame(list(cursor))
67
  raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
22
  fd_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']
23
 
24
  @st.cache_data(ttl = 60)
25
+ def init_DK_seed_frames(load_size):
26
 
27
  collection = db["DK_NBA_seed_frame"]
28
+ cursor = collection.find().limit(load_size)
29
 
30
  raw_display = pd.DataFrame(list(cursor))
31
  raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
34
  return DK_seed
35
 
36
  @st.cache_data(ttl = 60)
37
+ def init_DK_secondary_seed_frames(load_size):
38
 
39
  collection = db["DK_NBA_Secondary_seed_frame"]
40
+ cursor = collection.find().limit(load_size)
41
 
42
  raw_display = pd.DataFrame(list(cursor))
43
  raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
46
  return DK_secondary
47
 
48
  @st.cache_data(ttl = 60)
49
+ def init_FD_seed_frames(load_size):
50
 
51
  collection = db["FD_NBA_seed_frame"]
52
+ cursor = collection.find().limit(load_size)
53
 
54
  raw_display = pd.DataFrame(list(cursor))
55
  raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
 
58
  return FD_seed
59
 
60
  @st.cache_data(ttl = 60)
61
+ def init_FD_secondary_seed_frames(load_size):
62
 
63
  collection = db["FD_NBA_Secondary_seed_frame"]
64
+ cursor = collection.find().limit(load_size)
65
 
66
  raw_display = pd.DataFrame(list(cursor))
67
  raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]