Skip to content

Commit

Permalink
Merge pull request #175 from DMcP89/release/v0.4.4-Beta
Browse files Browse the repository at this point in the history
Release/v0.4.4 beta
  • Loading branch information
DMcP89 authored Oct 22, 2024
2 parents e1ad9bd + 59afb9b commit e2e1a35
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Harambot
_An interactive Yahoo Fantasy sports bot for Discord._

![Python](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue) ![License](https://img.shields.io/badge/License-MIT-green) ![Build](https://img.shields.io/github/actions/workflow/status/DMcP89/harambot/unit-tests.yml?branch=main) ![Version](https://img.shields.io/badge/version-0.4.2--Beta-red)
![Python](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue) ![License](https://img.shields.io/badge/License-MIT-green) ![Build](https://img.shields.io/github/actions/workflow/status/DMcP89/harambot/unit-tests.yml?branch=main) ![Version](https://img.shields.io/badge/version-0.4.4--Beta-red)



Expand Down
20 changes: 11 additions & 9 deletions harambot/cogs/yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ async def trade(self, interaction: discord.Interaction):
player_set0.append(player["name"])
api_details = (
self.get_player_text(
self.yahoo_api.get_player_details(player["name"], guild_id=interaction.guild_id)
self.yahoo_api.get_player_details(
player["name"], guild_id=interaction.guild_id
)
)
+ "\n"
)
Expand All @@ -155,7 +157,9 @@ async def trade(self, interaction: discord.Interaction):
player_set1_details = ""
for player in latest_trade["tradee_players"]:
player_set1.append(player["name"])
player_details = self.yahoo_api.get_player_details(player["name"], guild_id=interaction.guild_id)
player_details = self.yahoo_api.get_player_details(
player["name"], guild_id=interaction.guild_id
)
if player_details is None:
await interaction.followup.send(self.error_message)
return
Expand Down Expand Up @@ -267,13 +271,11 @@ def get_player_embed(self, player):
value=player["stats"]["total_points"],
inline=False,
)
del player["stats"]["player_id"]
del player["stats"]["name"]
del player["stats"]["position_type"]
for key, value in player["stats"].items():
if key == "total_points":
continue
embed.add_field(name=key, value=value)
if len(player["stats"].items()) < 20:
for key, value in player["stats"].items():
if key == "total_points":
continue
embed.add_field(name=key, value=value)
return embed

def get_player_text(self, player):
Expand Down
10 changes: 8 additions & 2 deletions harambot/yahoo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,22 @@ def get_player_details(self, player_name, guild_id, week=None):
player = self.league().player_details(player_name)[0]
player["owner"] = self.get_player_owner(player["player_id"])
if week:
player["stats"] = self.league().player_stats(
stats = self.league().player_stats(
[player["player_id"]],
req_type="week",
week=week,
)[0]
else:
player["stats"] = self.league().player_stats(
stats = self.league().player_stats(
[player["player_id"]],
req_type="season",
)[0]
del stats["player_id"]
del stats["name"]
del stats["position_type"]
if len(stats) > 20:
stats = {k: v for k, v in stats.items() if v != 0.0}
player["stats"] = stats
return player
except Exception:
logger.exception(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "harambot"
version = "0.4.3"
version = "0.4.4"
description = "A Yahoo Fantasy Sports bot for Discord"
authors = ["DMcP89 <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
- key: RUN_MIGRATIONS
sync: false
- key: VERSION
value: "0.4.3-Beta"
value: "0.4.4-Beta"

databases:
- name: harambot-database
Expand Down
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def mock_player_details():

@pytest.fixture
def mock_player_stats():
return [{"mock": "stats"}]
return [
{
"mock": "stats",
"player_id": "39077",
"name": "Josh Allen",
"position_type": "o",
}
]


@pytest.fixture
Expand Down
27 changes: 26 additions & 1 deletion tests/test-player-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,32 @@
"coverage_type": "season",
"season": "2020"
},
"stats": [{
"stats": [
{
"stat": {
"stat_id": "0",
"value": "396"
}
},
{
"stat": {
"stat_id": "1",
"value": "572"
}
},
{
"stat": {
"stat_id": "2",
"value": "4544"
}
},
{
"stat": {
"stat_id": "3",
"value": "37"
}
},
{
"stat": {
"stat_id": "4",
"value": "2871"
Expand Down

0 comments on commit e2e1a35

Please sign in to comment.