Alejadro Sanchez-Giraldo commited on
Commit
8b6f519
·
1 Parent(s): 796b25f

dream team

Browse files
Files changed (2) hide show
  1. fpl_client.py +9 -1
  2. nlp_utils.py +7 -1
fpl_client.py CHANGED
@@ -96,4 +96,12 @@ class FPLClient:
96
  players = self.data['elements']
97
  injuries = [(p['web_name'], p['news']) for p in players if p['news'] and 'injury' in p['news'].lower()]
98
  logging.debug(f"Injured players: {injuries}")
99
- return injuries
 
 
 
 
 
 
 
 
 
96
  players = self.data['elements']
97
  injuries = [(p['web_name'], p['news']) for p in players if p['news'] and 'injury' in p['news'].lower()]
98
  logging.debug(f"Injured players: {injuries}")
99
+ return injuries
100
+
101
+ # get list of Dream team by FPL by filtering Elements that have in_dreamteam: true
102
+ def dream_team(self):
103
+ logging.info("Fetching Dream Team")
104
+ players = self.data['elements']
105
+ dream_team = [p['web_name'] for p in players if p['in_dreamteam']== True]
106
+ logging.info(f"Dream Team: {dream_team}")
107
+ return dream_team
nlp_utils.py CHANGED
@@ -64,5 +64,11 @@ def process_query(query, fpl_client):
64
  formatted_injuries = "\n\n".join([f"Player: {name} Injury: {news}" for name, news in injuries])
65
  injury_count = len(injuries)
66
  return f"There are {injury_count} players with injuries:\n\n{formatted_injuries}"
67
-
 
 
 
 
 
 
68
  return "I'm not sure how to help with that."
 
64
  formatted_injuries = "\n\n".join([f"Player: {name} Injury: {news}" for name, news in injuries])
65
  injury_count = len(injuries)
66
  return f"There are {injury_count} players with injuries:\n\n{formatted_injuries}"
67
+
68
+ if "dream" in query.lower():
69
+ dt = fpl_client.dream_team()
70
+ if dt == []:
71
+ return "Dream Team not available"
72
+ return "Dream Team is:\n" + "\n".join(dt)
73
+
74
  return "I'm not sure how to help with that."