Skip to content
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 next session times #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyracing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ async def race_laps_all(
'subsessionid': subsession_id,
'carclassid': car_class_id,
'simsesnum': sim_session_type
}
}
url = ct.URL_LAPS_ALL
response = await self._build_request(url, payload)

Expand Down
11 changes: 10 additions & 1 deletion pyracing/response_objects/upcoming_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def __init__(self, data):
self.leave_marbles = data['15']
self.max_to_display = data['1']
self.race_week = data['32']
self.race_week_cars = data['26']
self.race_week_cars = [self.RaceWeekCars(x)
for x in data['26'].items()]
self.reg_count = data['16']
self.rubber_practice = data['13']
self.rubber_qualify = data['24']
Expand All @@ -174,3 +175,11 @@ def __init__(self, data):
self.wind_speed_value = data['4']
# Used outside of d dict; Holds refresh time of data
# self.reloadtime = dict['18']

class RaceWeekCars:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason for this class to be a part of the NextSessionTimes class, we may end up using it again if we find an endpoint that returns raceweekcars.

Also, we have one or two more, similar Car classes, is there potential for code reuse there? I know i have seen some type of car with an id and a max dry tire sets and so on before, so lets make sure we aren't repeating code just in case.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XanderRiga Isn't this nested class in line with how we have the other classes setup?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cases where we did that we were extending another Car and it was a type of car that we would never see anywhere else because they sent different data. I am not super sure that is the case here since they specifically refer to it as raceWeekCars, which to me implies this is a specific type of car that is a race week car, which I believe could be reused.

That being said, if we want to keep it as a class inside the other class it's fine, but we should at least be doing the extending of the base car and only adding the specific fields that don't exist in the base class here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The race_week_cars is an attribute of NextSessionTimes and RaceGuide.Schedule.Race so I agree that it doesn't make sense to subclass with NextSessionTimes. Also RaceWeekCars is a bit ambiguous since whilst it does list the car id for that session, it's more about some session specific attributes for those cars, which aren't really logical attributes of any other Car classes.

So logically it might sit better as a subclass of Race, but that makes it difficult to access from NextSessionTimes. Leaving it as a standalone class feels like the best place to define it and make it accessible to every object that needs access.

def __init__(self, data):
self.car_id = data[0]
self.max_percent_fuel_fill = data[1]["maxPctFuelFill"]
self.weight_penalty_kg = data[1]["weightPenaltyKG"]
self.max_dry_tire_sets = data[1]["max_dry_tire_sets"]
self.power_adjust_percent = data[1]["powerAdjustPct"]