Choose a user with booking availability among many
This commit is contained in:
parent
a8322d6be0
commit
559c3b6d69
18 changed files with 1810 additions and 147 deletions
|
@ -21,15 +21,30 @@ async def book(club: Club, user: User, booking_filter: BookingFilter) -> int | N
|
|||
return await platform.book(user, booking_filter)
|
||||
|
||||
|
||||
async def get_user_without_booking(club: Club, users: list[User]) -> User | None:
|
||||
"""
|
||||
Return the first user who has no booking
|
||||
|
||||
:param club: the club where to book
|
||||
:param users: the list of users
|
||||
:return: any user who has no booking
|
||||
"""
|
||||
async with GestionSportsPlatform(club) as platform:
|
||||
for user in users:
|
||||
if await platform.user_has_no_ongoing_booking(user):
|
||||
return user
|
||||
return None
|
||||
|
||||
|
||||
def main() -> int | None:
|
||||
"""
|
||||
Main function used to book a court
|
||||
|
||||
:return: the id of the booked court, or None if no court was booked
|
||||
"""
|
||||
user = config.get_user()
|
||||
booking_filter = config.get_booking_filter()
|
||||
club = config.get_club()
|
||||
user = asyncio.run(get_user_without_booking(club, config.get_available_users()))
|
||||
|
||||
LOGGER.info(
|
||||
"Starting booking court of sport %s for user %s at club %s at %s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue