-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Joined On info in Clubs/Players endpoint #68
Conversation
WalkthroughThe recent updates enhance the players' service within the clubs module and improve the handling of XPath queries. These changes primarily focus on logging player information and refining how players' joining dates are extracted and processed from HTML content. Changes
Sequence Diagram(s)sequenceDiagram
participant Service as PlayersService
participant XPathUtils as XPathUtilities
participant Logger as Logger
participant Page as PageContent
Service->>XPathUtils: Get `page_players_joined_on`
XPathUtils-->>Service: Return joined_on XPath data
Service->>Logger: Log value of `self.past`
Service->>Page: Extract `players_joined_on` data
Page-->>Service: Return players' joining dates
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- app/services/clubs/players.py (3 hunks)
- app/utils/xpath.py (1 hunks)
Additional comments not posted (3)
app/services/clubs/players.py (1)
78-78
: Ensure that the xpath expression used in the list comprehension correctly extracts the 'joined_on' data as intended.Verification successful
The
JOINED_ON
xpath is defined as".//text()"
inapp/utils/xpath.py
, and thepage_players_joined_on
variable is populated using the xpath expressionsClubs.Players.Past.PAGE_SIGNED_FROM
orClubs.Players.Present.PAGE_SIGNED_FROM
, which are defined as//div[@id='yw1']//td[8]
and//div[@id='yw1']//td[9]
respectively. This indicates that the xpath expressions used should correctly extract the 'joined_on' data as intended.
JOINED_ON
is defined as".//text()"
inapp/utils/xpath.py
.page_players_joined_on
is populated usingClubs.Players.Past.PAGE_SIGNED_FROM
orClubs.Players.Present.PAGE_SIGNED_FROM
.PAGE_SIGNED_FROM
is defined as//div[@id='yw1']//td[8]
and//div[@id='yw1']//td[9]
.These definitions align correctly with the intended data extraction for 'joined_on'.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the xpath used in the 'joined_on' extraction returns expected results. # Test: Run a sample extraction using the xpath to ensure correct data is retrieved. ast-grep --lang python --pattern $'self.page.xpath(Clubs.Players.JOINED_ON)'Length of output: 77
Script:
#!/bin/bash # Locate the definition of 'JOINED_ON' within the 'Clubs.Players' context ast-grep --lang python --pattern $'JOINED_ON = $_' --search 'Clubs.Players'Length of output: 274
Script:
#!/bin/bash # Locate the definition of 'JOINED_ON' within the 'Clubs.Players' context ast-grep --lang python --pattern $'JOINED_ON = $_' 'Clubs/Players'Length of output: 126
Script:
#!/bin/bash # Locate the definition of 'JOINED_ON' in the entire codebase ast-grep --lang python --pattern $'JOINED_ON = $_'Length of output: 108
Script:
#!/bin/bash # Locate the definition and usage of 'page_players_joined_on' in the codebase ast-grep --lang python --pattern $'page_players_joined_on = $_'Length of output: 335
Script:
#!/bin/bash # Locate the definitions of 'PAGE_SIGNED_FROM' in the codebase ast-grep --lang python --pattern $'PAGE_SIGNED_FROM = $_'Length of output: 222
app/utils/xpath.py (2)
152-152
: Adding the 'JOINED_ON' xpath at the top level of the 'Players' class is a good practice for reusability across different methods.
156-156
: Ensure the newly added xpath attributes for 'PAGE_JOINED_ON' are correct and match the actual HTML structure of the page.Also applies to: 163-163
@@ -38,6 +38,7 @@ def __update_season_id(self): | |||
def __update_past_flag(self) -> None: | |||
"""Check if the season is the current or if it's a past one and update the flag accordingly.""" | |||
self.past = "Current club" in self.get_list_by_xpath(Clubs.Players.PAST_FLAG) | |||
print(f"{self.past=}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing the print statement with a proper logging mechanism for better control over log levels and outputs.
page_players_joined_on = self.page.xpath( | ||
Clubs.Players.Past.PAGE_SIGNED_FROM if self.past else Clubs.Players.Present.PAGE_SIGNED_FROM, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears there is a copy-paste error here. The xpath should be for 'JOINED_ON' instead of reusing 'SIGNED_FROM'.
- page_players_joined_on = self.page.xpath(
- Clubs.Players.Past.PAGE_SIGNED_FROM if self.past else Clubs.Players.Present.PAGE_SIGNED_FROM,
- )
+ page_players_joined_on = self.page.xpath(
+ Clubs.Players.Past.PAGE_JOINED_ON if self.past else Clubs.Players.Present.PAGE_JOINED_ON,
+ )
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
page_players_joined_on = self.page.xpath( | |
Clubs.Players.Past.PAGE_SIGNED_FROM if self.past else Clubs.Players.Present.PAGE_SIGNED_FROM, | |
) | |
page_players_joined_on = self.page.xpath( | |
Clubs.Players.Past.PAGE_JOINED_ON if self.past else Clubs.Players.Present.PAGE_JOINED_ON, | |
) |
Summary by CodeRabbit
New Features
Bug Fixes