Skip to content

Commit

Permalink
feat: add contracts to clubs players (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeall authored Aug 14, 2024
1 parent 62cfa0c commit 41a0d4b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/services/clubs/players.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def __parse_club_players(self) -> list[dict]:
players_joined_on = ["; ".join(e.xpath(Clubs.Players.JOINED_ON)) for e in page_players_joined_on]
players_joined = ["; ".join(e.xpath(Clubs.Players.JOINED)) for e in page_players_infos]
players_signed_from = ["; ".join(e.xpath(Clubs.Players.SIGNED_FROM)) for e in page_players_signed_from]
players_contracts = (
[None] * len(players_ids) if self.past else self.get_list_by_xpath(Clubs.Players.Present.CONTRACTS)
)
players_marketvalues = self.get_list_by_xpath(Clubs.Players.MARKET_VALUES)
players_statuses = ["; ".join(e.xpath(Clubs.Players.STATUSES)) for e in page_players_infos]

Expand All @@ -94,10 +97,11 @@ def __parse_club_players(self) -> list[dict]:
"joinedOn": joined_on,
"joined": joined,
"signedFrom": signed_from,
"contract": contract,
"marketValue": market_value,
"status": status,
}
for idx, name, position, dob, age, nationality, current_club, height, foot, joined_on, joined, signed_from, market_value, status, in zip( # noqa: E501
for idx, name, position, dob, age, nationality, current_club, height, foot, joined_on, joined, signed_from, contract, market_value, status, in zip( # noqa: E501
players_ids,
players_names,
players_positions,
Expand All @@ -110,6 +114,7 @@ def __parse_club_players(self) -> list[dict]:
players_joined_on,
players_joined,
players_signed_from,
players_contracts,
players_marketvalues,
players_statuses,
)
Expand Down
1 change: 1 addition & 0 deletions app/utils/xpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class Present:
PAGE_JOINED_ON = "//div[@id='yw1']//td[7]"
HEIGHTS = "//div[@id='yw1']//td[5]//text()"
FOOTS = "//div[@id='yw1']//td[6]//text()"
CONTRACTS = "//div[@id='yw1']//td[9]//text()"

class Past:
PAGE_SIGNED_FROM = "//div[@id='yw1']//td[9]"
Expand Down
1 change: 1 addition & 0 deletions tests/clubs/test_clubs_players.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_get_club_players(
"joinedOn": Or("", And(str, len_greater_than_0, regex_date_mmm_dd_yyyy)),
"joined": Or("", And(str, len_greater_than_0)),
"signedFrom": Or("", And(str, len_greater_than_0)),
"contract": Or(None, And(str, regex_date_mmm_dd_yyyy)),
"marketValue": And(str, len_greater_than_0, regex_market_value),
"status": Or("", And(str, len_greater_than_0)),
},
Expand Down

0 comments on commit 41a0d4b

Please sign in to comment.