multiple resource id support
This commit is contained in:
parent
a62cb344b4
commit
4f4046e4a0
2 changed files with 19 additions and 7 deletions
|
|
@ -11,6 +11,8 @@ SERVICE_ID = "601"
|
||||||
# RESOURCE_ID =16402 # 222 study room
|
# RESOURCE_ID =16402 # 222 study room
|
||||||
# RESOURCE_ID =15883 #66 second best
|
# RESOURCE_ID =15883 #66 second best
|
||||||
RESOURCE_ID = 15502 # 17 cool snipe with view
|
RESOURCE_ID = 15502 # 17 cool snipe with view
|
||||||
|
RESOURCE_IDS = []
|
||||||
|
# RESOURCE_IDS = [15502, 15883]
|
||||||
|
|
||||||
TIMEZONE = "Europe/Berlin"
|
TIMEZONE = "Europe/Berlin"
|
||||||
# SSO_PROVIDER = "kit" # Available: kit (add more in auth/providers/)
|
# SSO_PROVIDER = "kit" # Available: kit (add more in auth/providers/)
|
||||||
|
|
|
||||||
24
main.py
24
main.py
|
|
@ -7,7 +7,7 @@ from auth.session import AnnySession
|
||||||
from booking.client import BookingClient
|
from booking.client import BookingClient
|
||||||
from utils.helpers import get_future_datetime
|
from utils.helpers import get_future_datetime
|
||||||
import pytz
|
import pytz
|
||||||
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES
|
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES, RESOURCE_IDS
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -48,15 +48,25 @@ def main():
|
||||||
start = get_future_datetime(hour=time_["start"])
|
start = get_future_datetime(hour=time_["start"])
|
||||||
end = get_future_datetime(hour=time_["end"])
|
end = get_future_datetime(hour=time_["end"])
|
||||||
|
|
||||||
|
# maybe add if reservation fails try next id and if everything fails do ^
|
||||||
|
|
||||||
|
for seat_id in RESOURCE_IDS:
|
||||||
|
resource_id = seat_id
|
||||||
|
reservation_success = booking.reserve(resource_id, start, end)
|
||||||
|
if reservation_success:
|
||||||
|
return True
|
||||||
|
|
||||||
if RESOURCE_ID:
|
if RESOURCE_ID:
|
||||||
resource_id = RESOURCE_ID
|
resource_id = RESOURCE_ID
|
||||||
|
reservation_success = booking.reserve(resource_id, start, end)
|
||||||
|
if reservation_success:
|
||||||
|
return True
|
||||||
|
resource_id = booking.find_available_resource(start, end)
|
||||||
|
reservation_success = booking.reserve(resource_id, start, end)
|
||||||
|
if reservation_success:
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
resource_id = booking.find_available_resource(start, end)
|
print("⚠️ No available slots found. ( or other error )")
|
||||||
|
|
||||||
if resource_id:
|
|
||||||
booking.reserve(resource_id, start, end)
|
|
||||||
else:
|
|
||||||
print("⚠️ No available slots found.")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Error booking slot {time_['start']}-{time_['end']}: {e}")
|
print(f"❌ Error booking slot {time_['start']}-{time_['end']}: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue