From 716a565713c1078b869505833fc0224acb77c2f0 Mon Sep 17 00:00:00 2001 From: i Date: Sat, 7 Feb 2026 13:50:59 +0100 Subject: [PATCH] new --- booking/client.py | 7 +- config/constants.py | 7 +- data.json | 1432 ++++++++++++++++++++++++++++++++++++++++ development_process.md | 4 + main.py | 14 +- resource_id_helper.py | 22 +- 6 files changed, 1471 insertions(+), 15 deletions(-) create mode 100644 data.json create mode 100644 development_process.md diff --git a/booking/client.py b/booking/client.py index 424667c..207a0b6 100644 --- a/booking/client.py +++ b/booking/client.py @@ -71,6 +71,7 @@ class BookingClient: "customer_note": "", "add_ons_by_service": {SERVICE_ID: [[]]}, "sub_bookings_by_service": {}, + # INFO: changes every week: e.g. booking for a monday needs new id # "booking_quota_grant_id":"24735199", "booking_quota_grant_id": "24735202", "strategy": "multi-resource", @@ -86,8 +87,10 @@ class BookingClient: try: data = booking.json().get("data", {}) except (ValueError, JSONDecodeError): - # print(f"❌ Invalid JSON response from booking request: {booking.text[:200]}") - print(f"❌ Invalid JSON response from booking request: {booking.text}") + if "Bad Request" in booking.text and "400" in booking.text: + print("❌ Bad Request 400 on Booking request.") + else: + print(f"❌ Invalid JSON response from booking request: {booking.text}") return False oid = data.get("id") diff --git a/config/constants.py b/config/constants.py index 5e04b18..31144c8 100644 --- a/config/constants.py +++ b/config/constants.py @@ -10,9 +10,10 @@ SERVICE_ID = "601" # RESOURCE_ID =15994 # 91 height adjustable desk # RESOURCE_ID =16402 # 222 study room # RESOURCE_ID =15883 #66 second best -RESOURCE_ID = 15502 # 17 cool snipe with view -RESOURCE_IDS = [] -# RESOURCE_IDS = [15502, 15883] +# RESOURCE_ID = 15502 # 17 cool snipe with view +# RESOURCE_IDS = [15502, 15883, 16402] +# RESOURCE_ID = None +RESOURCE_IDS = [15883, 15502, 15880, 15505, 15892] TIMEZONE = "Europe/Berlin" # SSO_PROVIDER = "kit" # Available: kit (add more in auth/providers/) diff --git a/data.json b/data.json new file mode 100644 index 0000000..27e9e9e --- /dev/null +++ b/data.json @@ -0,0 +1,1432 @@ +{ + "data": [ + { + "id": "15454", + "attributes": { + "name": "Desk No. 1 | on gallery" + } + }, + { + "id": "15460", + "attributes": { + "name": "Desk No. 3 | on gallery" + } + }, + { + "id": "15463", + "attributes": { + "name": "Desk No. 4 | on gallery" + } + }, + { + "id": "15466", + "attributes": { + "name": "Desk No. 5 | on gallery" + } + }, + { + "id": "15469", + "attributes": { + "name": "Desk No. 6 | on gallery" + } + }, + { + "id": "15472", + "attributes": { + "name": "Desk No. 7 | on gallery" + } + }, + { + "id": "15475", + "attributes": { + "name": "Desk No. 8 | on gallery" + } + }, + { + "id": "15481", + "attributes": { + "name": "Desk No. 10 | on gallery" + } + }, + { + "id": "15484", + "attributes": { + "name": "Desk No. 11 | on gallery" + } + }, + { + "id": "15487", + "attributes": { + "name": "Desk No. 12 | on gallery" + } + }, + { + "id": "15490", + "attributes": { + "name": "Desk No. 13 | on gallery" + } + }, + { + "id": "15493", + "attributes": { + "name": "Desk No. 14 | on gallery" + } + }, + { + "id": "15499", + "attributes": { + "name": "Desk No. 16 | on gallery" + } + }, + { + "id": "15505", + "attributes": { + "name": "Desk No. 18 | on gallery" + } + }, + { + "id": "15547", + "attributes": { + "name": "Desk No. 20 | on gallery" + } + }, + { + "id": "15550", + "attributes": { + "name": "Desk No. 21 | on gallery" + } + }, + { + "id": "15553", + "attributes": { + "name": "Desk No. 22 | on gallery" + } + }, + { + "id": "15556", + "attributes": { + "name": "Desk No. 23 | on gallery" + } + }, + { + "id": "15559", + "attributes": { + "name": "Desk No. 24 | on gallery" + } + }, + { + "id": "15562", + "attributes": { + "name": "Desk No. 25 | on gallery" + } + }, + { + "id": "15565", + "attributes": { + "name": "Desk No. 26 | on gallery" + } + }, + { + "id": "15568", + "attributes": { + "name": "Desk No. 27 | on gallery" + } + }, + { + "id": "15574", + "attributes": { + "name": "Desk No. 29 | on gallery" + } + }, + { + "id": "15577", + "attributes": { + "name": "Desk No. 30 | on gallery" + } + }, + { + "id": "15778", + "attributes": { + "name": "Desk No. 31 | on gallery" + } + }, + { + "id": "15781", + "attributes": { + "name": "Desk No. 32 | on gallery" + } + }, + { + "id": "15784", + "attributes": { + "name": "Desk No. 33 | on gallery" + } + }, + { + "id": "15787", + "attributes": { + "name": "Desk No. 34 | on gallery" + } + }, + { + "id": "15790", + "attributes": { + "name": "Desk No. 35 | on gallery" + } + }, + { + "id": "15793", + "attributes": { + "name": "Desk No. 36 | on gallery" + } + }, + { + "id": "15796", + "attributes": { + "name": "Desk No. 37 | on gallery" + } + }, + { + "id": "15799", + "attributes": { + "name": "Desk No. 38 | on gallery" + } + }, + { + "id": "15802", + "attributes": { + "name": "Desk No. 39 | on gallery" + } + }, + { + "id": "15805", + "attributes": { + "name": "Desk No. 40 | on gallery" + } + }, + { + "id": "15808", + "attributes": { + "name": "Desk No. 41 | on gallery" + } + }, + { + "id": "15811", + "attributes": { + "name": "Desk No. 42 | on gallery" + } + }, + { + "id": "15817", + "attributes": { + "name": "Desk No. 44 | on gallery" + } + }, + { + "id": "15820", + "attributes": { + "name": "Desk No. 45 | on gallery" + } + }, + { + "id": "15823", + "attributes": { + "name": "Desk No. 46 | on gallery" + } + }, + { + "id": "15826", + "attributes": { + "name": "Desk No. 47 | on gallery" + } + }, + { + "id": "15829", + "attributes": { + "name": "Desk No. 48 | on gallery" + } + }, + { + "id": "15832", + "attributes": { + "name": "Desk No. 49 | on gallery" + } + }, + { + "id": "15835", + "attributes": { + "name": "Desk No. 50 | on gallery" + } + }, + { + "id": "15838", + "attributes": { + "name": "Desk No. 51 | on gallery" + } + }, + { + "id": "15841", + "attributes": { + "name": "Desk No. 52 | on gallery" + } + }, + { + "id": "15844", + "attributes": { + "name": "Desk No. 53 | on gallery" + } + }, + { + "id": "15847", + "attributes": { + "name": "Desk No. 54 | on gallery" + } + }, + { + "id": "15850", + "attributes": { + "name": "Desk No. 55 | on gallery" + } + }, + { + "id": "15853", + "attributes": { + "name": "Desk No. 56 | on gallery" + } + }, + { + "id": "15856", + "attributes": { + "name": "Desk No. 57 | on gallery" + } + }, + { + "id": "15859", + "attributes": { + "name": "Desk No. 58 | on gallery" + } + }, + { + "id": "15862", + "attributes": { + "name": "Desk No. 59 | on gallery" + } + }, + { + "id": "15865", + "attributes": { + "name": "Desk No. 60 | on gallery" + } + }, + { + "id": "15868", + "attributes": { + "name": "Desk No. 61 | on gallery" + } + }, + { + "id": "15871", + "attributes": { + "name": "Desk No. 62 | on gallery" + } + }, + { + "id": "15874", + "attributes": { + "name": "Desk No. 63 | on gallery" + } + }, + { + "id": "15877", + "attributes": { + "name": "Desk No. 64 | on gallery" + } + }, + { + "id": "15880", + "attributes": { + "name": "Desk No. 65 | on gallery" + } + }, + { + "id": "15883", + "attributes": { + "name": "Desk No. 66 | on gallery" + } + }, + { + "id": "15886", + "attributes": { + "name": "Desk No. 67 | on gallery" + } + }, + { + "id": "15889", + "attributes": { + "name": "Desk No. 68 | on gallery" + } + }, + { + "id": "15892", + "attributes": { + "name": "Desk No. 69 | on gallery" + } + }, + { + "id": "15895", + "attributes": { + "name": "Desk No. 70 | on gallery" + } + }, + { + "id": "15898", + "attributes": { + "name": "Desk No. 71 | on gallery" + } + }, + { + "id": "15901", + "attributes": { + "name": "Desk No. 72 | on gallery" + } + }, + { + "id": "15904", + "attributes": { + "name": "Desk No. 73 | on gallery" + } + }, + { + "id": "15907", + "attributes": { + "name": "Desk No. 74 | on gallery" + } + }, + { + "id": "15910", + "attributes": { + "name": "Desk No. 75 | on gallery" + } + }, + { + "id": "15913", + "attributes": { + "name": "Desk No. 76 | on gallery" + } + }, + { + "id": "15916", + "attributes": { + "name": "Desk No. 77 | on gallery" + } + }, + { + "id": "15919", + "attributes": { + "name": "Desk No. 78 | on gallery" + } + }, + { + "id": "15922", + "attributes": { + "name": "Desk No. 79 | on gallery" + } + }, + { + "id": "15925", + "attributes": { + "name": "Desk No. 80 | on gallery" + } + }, + { + "id": "15928", + "attributes": { + "name": "Desk No. 81 | on gallery" + } + }, + { + "id": "15931", + "attributes": { + "name": "Desk No. 82 | on gallery" + } + }, + { + "id": "15934", + "attributes": { + "name": "Desk No. 83 | on gallery" + } + }, + { + "id": "15937", + "attributes": { + "name": "Desk No. 84 | on gallery" + } + }, + { + "id": "15976", + "attributes": { + "name": "Desk No. 85 | height-adjustable" + } + }, + { + "id": "15982", + "attributes": { + "name": "Desk No. 87 | height-adjustable" + } + }, + { + "id": "15985", + "attributes": { + "name": "Desk No. 88 | height-adjustable" + } + }, + { + "id": "15988", + "attributes": { + "name": "Desk No. 89 | height-adjustable" + } + }, + { + "id": "15994", + "attributes": { + "name": "Desk No. 91 | height-adjustable" + } + }, + { + "id": "15997", + "attributes": { + "name": "Desk No. 92 | height-adjustable" + } + }, + { + "id": "16000", + "attributes": { + "name": "Desk No. 93 | height-adjustable" + } + }, + { + "id": "16003", + "attributes": { + "name": "Desk No. 94 | height-adjustable" + } + }, + { + "id": "16006", + "attributes": { + "name": "Desk No. 95 | height-adjustable" + } + }, + { + "id": "16009", + "attributes": { + "name": "Desk No. 96 | height-adjustable" + } + }, + { + "id": "16012", + "attributes": { + "name": "Desk No. 97 | height-adjustable" + } + }, + { + "id": "16015", + "attributes": { + "name": "Desk No. 98 | height-adjustable" + } + }, + { + "id": "16018", + "attributes": { + "name": "Desk No. 99 | height-adjustable" + } + }, + { + "id": "16021", + "attributes": { + "name": "Desk No. 100 | height-adjustable" + } + }, + { + "id": "16024", + "attributes": { + "name": "Desk No. 101 | height-adjustable" + } + }, + { + "id": "16027", + "attributes": { + "name": "Desk No. 102 | height-adjustable" + } + }, + { + "id": "16030", + "attributes": { + "name": "Desk No. 103 | height-adjustable" + } + }, + { + "id": "16033", + "attributes": { + "name": "Desk No. 104 | height-adjustable" + } + }, + { + "id": "16036", + "attributes": { + "name": "Desk No. 105 | height-adjustable" + } + }, + { + "id": "16039", + "attributes": { + "name": "Desk No. 106 | height-adjustable" + } + }, + { + "id": "16042", + "attributes": { + "name": "Desk No. 107 | height-adjustable" + } + }, + { + "id": "16045", + "attributes": { + "name": "Desk No. 108 | height-adjustable" + } + }, + { + "id": "16048", + "attributes": { + "name": "Desk No. 109 | height-adjustable" + } + }, + { + "id": "16051", + "attributes": { + "name": "Desk No. 110 | height-adjustable" + } + }, + { + "id": "16054", + "attributes": { + "name": "Desk No. 111 | height-adjustable" + } + }, + { + "id": "16057", + "attributes": { + "name": "Desk No. 112 | height-adjustable" + } + }, + { + "id": "16060", + "attributes": { + "name": "Desk No. 113 | height-adjustable" + } + }, + { + "id": "16063", + "attributes": { + "name": "Desk No. 114 | height-adjustable" + } + }, + { + "id": "16066", + "attributes": { + "name": "Desk No. 115 | height-adjustable" + } + }, + { + "id": "16069", + "attributes": { + "name": "Desk No. 116 | height-adjustable" + } + }, + { + "id": "16072", + "attributes": { + "name": "Desk No. 117 | height-adjustable" + } + }, + { + "id": "16075", + "attributes": { + "name": "Desk No. 118 | height-adjustable" + } + }, + { + "id": "16078", + "attributes": { + "name": "Desk No. 119 | height-adjustable" + } + }, + { + "id": "16081", + "attributes": { + "name": "Desk No. 120 | height-adjustable" + } + }, + { + "id": "16084", + "attributes": { + "name": "Desk No. 121 | height-adjustable" + } + }, + { + "id": "16087", + "attributes": { + "name": "Desk No. 122 | height-adjustable" + } + }, + { + "id": "16090", + "attributes": { + "name": "Desk No. 123 | height-adjustable" + } + }, + { + "id": "16093", + "attributes": { + "name": "Desk No. 124 | height-adjustable" + } + }, + { + "id": "16096", + "attributes": { + "name": "Desk No. 125 | height-adjustable" + } + }, + { + "id": "16099", + "attributes": { + "name": "Desk No. 126 | height-adjustable" + } + }, + { + "id": "16102", + "attributes": { + "name": "Desk No. 127 | height-adjustable" + } + }, + { + "id": "16105", + "attributes": { + "name": "Desk No. 128 | height-adjustable" + } + }, + { + "id": "16108", + "attributes": { + "name": "Desk No. 129 | height-adjustable" + } + }, + { + "id": "16111", + "attributes": { + "name": "Desk No. 130 | height-adjustable" + } + }, + { + "id": "16114", + "attributes": { + "name": "Desk No. 131 | height-adjustable" + } + }, + { + "id": "16117", + "attributes": { + "name": "Desk No. 132 | height-adjustable" + } + }, + { + "id": "16120", + "attributes": { + "name": "Desk No. 133 | height-adjustable" + } + }, + { + "id": "16123", + "attributes": { + "name": "Desk No. 134 | height-adjustable" + } + }, + { + "id": "16126", + "attributes": { + "name": "Desk No. 135 | height-adjustable" + } + }, + { + "id": "16129", + "attributes": { + "name": "Desk No. 136 | height-adjustable" + } + }, + { + "id": "16132", + "attributes": { + "name": "Desk No. 137 | height-adjustable" + } + }, + { + "id": "16135", + "attributes": { + "name": "Desk No. 138 | height-adjustable" + } + }, + { + "id": "16138", + "attributes": { + "name": "Desk No. 139 | height-adjustable" + } + }, + { + "id": "16141", + "attributes": { + "name": "Desk No. 140 | height-adjustable" + } + }, + { + "id": "16162", + "attributes": { + "name": "Desk No. 142 | height-adjustable" + } + }, + { + "id": "16168", + "attributes": { + "name": "Desk No. 144 | height-adjustable" + } + }, + { + "id": "16171", + "attributes": { + "name": "Desk No. 145 | reading room" + } + }, + { + "id": "16174", + "attributes": { + "name": "Desk No. 146 | reading room" + } + }, + { + "id": "16177", + "attributes": { + "name": "Desk No. 147 | reading room" + } + }, + { + "id": "16180", + "attributes": { + "name": "Desk No. 148 | reading room" + } + }, + { + "id": "16183", + "attributes": { + "name": "Desk No. 149 | reading room" + } + }, + { + "id": "16186", + "attributes": { + "name": "Desk No. 150 | reading room" + } + }, + { + "id": "16189", + "attributes": { + "name": "Desk No. 151 | reading room" + } + }, + { + "id": "16192", + "attributes": { + "name": "Desk No. 152 | reading room" + } + }, + { + "id": "16195", + "attributes": { + "name": "Desk No. 153 | reading room" + } + }, + { + "id": "16198", + "attributes": { + "name": "Desk No. 154 | reading room" + } + }, + { + "id": "16201", + "attributes": { + "name": "Desk No. 155 | reading room" + } + }, + { + "id": "16204", + "attributes": { + "name": "Desk No. 156 | reading room" + } + }, + { + "id": "16207", + "attributes": { + "name": "Desk No. 157 | reading room" + } + }, + { + "id": "16210", + "attributes": { + "name": "Desk No. 158 | reading room" + } + }, + { + "id": "16213", + "attributes": { + "name": "Desk No. 159 | reading room" + } + }, + { + "id": "16216", + "attributes": { + "name": "Desk No. 160 | reading room" + } + }, + { + "id": "16219", + "attributes": { + "name": "Desk No. 161 | reading room" + } + }, + { + "id": "16222", + "attributes": { + "name": "Desk No. 162 | reading room" + } + }, + { + "id": "16225", + "attributes": { + "name": "Desk No. 163 | reading room" + } + }, + { + "id": "16228", + "attributes": { + "name": "Desk No. 164 | reading room" + } + }, + { + "id": "16231", + "attributes": { + "name": "Desk No. 165 | reading room" + } + }, + { + "id": "16234", + "attributes": { + "name": "Desk No. 166 | reading room" + } + }, + { + "id": "16237", + "attributes": { + "name": "Desk No. 167 | reading room" + } + }, + { + "id": "16240", + "attributes": { + "name": "Desk No. 168 | reading room" + } + }, + { + "id": "16243", + "attributes": { + "name": "Desk No. 169 | reading room" + } + }, + { + "id": "16246", + "attributes": { + "name": "Desk No. 170 | reading room" + } + }, + { + "id": "16249", + "attributes": { + "name": "Desk No. 171 | reading room" + } + }, + { + "id": "16252", + "attributes": { + "name": "Desk No. 172 | reading room" + } + }, + { + "id": "16255", + "attributes": { + "name": "Desk No. 173 | reading room" + } + }, + { + "id": "16258", + "attributes": { + "name": "Desk No. 174 | reading room" + } + }, + { + "id": "16261", + "attributes": { + "name": "Desk No. 175 | reading room" + } + }, + { + "id": "16264", + "attributes": { + "name": "Desk No. 176 | reading room" + } + }, + { + "id": "16267", + "attributes": { + "name": "Desk No. 177 | reading room" + } + }, + { + "id": "16273", + "attributes": { + "name": "Desk No. 179 | reading room" + } + }, + { + "id": "16276", + "attributes": { + "name": "Desk No. 180 | reading room" + } + }, + { + "id": "16279", + "attributes": { + "name": "Desk No. 181 | reading room" + } + }, + { + "id": "16282", + "attributes": { + "name": "Desk No. 182 | reading room" + } + }, + { + "id": "16285", + "attributes": { + "name": "Desk No. 183 | reading room" + } + }, + { + "id": "16288", + "attributes": { + "name": "Desk No. 184 | reading room" + } + }, + { + "id": "16291", + "attributes": { + "name": "Desk No. 185 | reading room" + } + }, + { + "id": "16294", + "attributes": { + "name": "Desk No. 186 | reading room" + } + }, + { + "id": "16297", + "attributes": { + "name": "Desk No. 187 | reading room" + } + }, + { + "id": "16300", + "attributes": { + "name": "Desk No. 188 | reading room" + } + }, + { + "id": "16303", + "attributes": { + "name": "Desk No. 189 | reading room" + } + }, + { + "id": "16306", + "attributes": { + "name": "Desk No. 190 | reading room" + } + }, + { + "id": "16309", + "attributes": { + "name": "Desk No. 191 | reading room" + } + }, + { + "id": "16312", + "attributes": { + "name": "Desk No. 192 | reading room" + } + }, + { + "id": "16315", + "attributes": { + "name": "Desk No. 193 | reading room" + } + }, + { + "id": "16318", + "attributes": { + "name": "Desk No. 194 | reading room" + } + }, + { + "id": "16321", + "attributes": { + "name": "Desk No. 195 | reading room" + } + }, + { + "id": "16324", + "attributes": { + "name": "Desk No. 196 | reading room" + } + }, + { + "id": "16330", + "attributes": { + "name": "Desk No. 198 | reading room" + } + }, + { + "id": "16333", + "attributes": { + "name": "Desk No. 199 | reading room" + } + }, + { + "id": "16336", + "attributes": { + "name": "Desk No. 200 | reading room" + } + }, + { + "id": "16339", + "attributes": { + "name": "Desk No. 201 | reading room" + } + }, + { + "id": "16342", + "attributes": { + "name": "Desk No. 202 | reading room" + } + }, + { + "id": "16345", + "attributes": { + "name": "Desk No. 203 | reading room" + } + }, + { + "id": "16348", + "attributes": { + "name": "Desk No. 204 | reading room" + } + }, + { + "id": "16351", + "attributes": { + "name": "Desk No. 205 | reading room" + } + }, + { + "id": "16357", + "attributes": { + "name": "Desk No. 207 | reading room" + } + }, + { + "id": "16360", + "attributes": { + "name": "Desk No. 208 | reading room" + } + }, + { + "id": "16363", + "attributes": { + "name": "Desk No. 209 | reading room" + } + }, + { + "id": "16366", + "attributes": { + "name": "Desk No. 210 | reading room" + } + }, + { + "id": "16369", + "attributes": { + "name": "Desk No. 211 | reading room" + } + }, + { + "id": "16372", + "attributes": { + "name": "Desk No. 212 | reading room" + } + }, + { + "id": "16375", + "attributes": { + "name": "Desk No. 213 | reading room" + } + }, + { + "id": "16378", + "attributes": { + "name": "Desk No. 214 | reading room" + } + }, + { + "id": "16381", + "attributes": { + "name": "Desk No. 215 | reading room" + } + }, + { + "id": "16384", + "attributes": { + "name": "Desk No. 216 | reading room" + } + }, + { + "id": "16387", + "attributes": { + "name": "Desk No. 217 | reading room" + } + }, + { + "id": "16390", + "attributes": { + "name": "Desk No. 218 | reading room" + } + }, + { + "id": "16393", + "attributes": { + "name": "Desk No. 219 | reading room" + } + }, + { + "id": "16396", + "attributes": { + "name": "Desk No. 220 | reading room" + } + }, + { + "id": "16399", + "attributes": { + "name": "Desk No. 221 | reading room" + } + }, + { + "id": "16402", + "attributes": { + "name": "Desk No. 222 | reading room" + } + }, + { + "id": "16405", + "attributes": { + "name": "Desk No. 223 | reading room" + } + }, + { + "id": "16408", + "attributes": { + "name": "Desk No. 224 | reading room" + } + }, + { + "id": "16411", + "attributes": { + "name": "Desk No. 225 | reading room" + } + }, + { + "id": "16414", + "attributes": { + "name": "Desk No. 226 | reading room" + } + }, + { + "id": "16417", + "attributes": { + "name": "Desk No. 227 | reading room" + } + }, + { + "id": "16420", + "attributes": { + "name": "Desk No. 228 | reading room" + } + }, + { + "id": "16423", + "attributes": { + "name": "Desk No. 229 | reading room" + } + }, + { + "id": "16426", + "attributes": { + "name": "Desk No. 230 | reading room" + } + }, + { + "id": "16429", + "attributes": { + "name": "Desk No. 231 | reading room" + } + }, + { + "id": "16432", + "attributes": { + "name": "Desk No. 232 | reading room" + } + }, + { + "id": "16435", + "attributes": { + "name": "Desk No. 233 | reading room" + } + }, + { + "id": "16438", + "attributes": { + "name": "Desk No. 234 | reading room" + } + }, + { + "id": "16441", + "attributes": { + "name": "Desk No. 235 | reading room" + } + }, + { + "id": "16444", + "attributes": { + "name": "Desk No. 236 | reading room" + } + }, + { + "id": "16447", + "attributes": { + "name": "Desk No. 237 | reading room" + } + }, + { + "id": "16450", + "attributes": { + "name": "Desk No. 238 | reading room" + } + }, + { + "id": "16453", + "attributes": { + "name": "Desk No. 239 | reading room" + } + }, + { + "id": "16456", + "attributes": { + "name": "Desk No. 240 | reading room" + } + }, + { + "id": "16459", + "attributes": { + "name": "Desk No. 241 | reading room" + } + }, + { + "id": "16462", + "attributes": { + "name": "Desk No. 242 | reading room" + } + }, + { + "id": "16465", + "attributes": { + "name": "Desk No. 243 | reading room" + } + }, + { + "id": "16468", + "attributes": { + "name": "Desk No. 244 | reading room" + } + }, + { + "id": "16471", + "attributes": { + "name": "Desk No. 245 | reading room" + } + }, + { + "id": "16474", + "attributes": { + "name": "Desk No. 246 | reading room" + } + }, + { + "id": "16477", + "attributes": { + "name": "Desk No. 247 | reading room" + } + }, + { + "id": "16480", + "attributes": { + "name": "Desk No. 248 | reading room" + } + }, + { + "id": "16483", + "attributes": { + "name": "Desk No. 249 | reading room" + } + }, + { + "id": "16486", + "attributes": { + "name": "Desk No. 250 | reading room" + } + }, + { + "id": "16489", + "attributes": { + "name": "Desk No. 251 | reading room" + } + }, + { + "id": "16492", + "attributes": { + "name": "Desk No. 252 | reading room" + } + } + ] +} \ No newline at end of file diff --git a/development_process.md b/development_process.md new file mode 100644 index 0000000..e4e1d1b --- /dev/null +++ b/development_process.md @@ -0,0 +1,4 @@ + + +1. add support for changing week ID automatically +2. only use resource_ids list and remove others diff --git a/main.py b/main.py index ade62f9..c224c84 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from auth.session import AnnySession from booking.client import BookingClient from utils.helpers import get_future_datetime import pytz -from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES, RESOURCE_IDS +from config.constants import TIMEZONE, SSO_PROVIDER, BOOKING_TIMES, RESOURCE_IDS def main(): @@ -38,7 +38,7 @@ def main(): max_wait_seconds = 10 * 60 # 10 minutes if 0 < seconds_until_midnight <= max_wait_seconds: - print("⏳ Waiting {seconds_until_midnight:.0f} seconds until midnight...") + print(f"⏳ Waiting {seconds_until_midnight:.0f} seconds until midnight...") time.sleep(seconds_until_midnight) elif seconds_until_midnight > max_wait_seconds: print("⚡ More than 10 min until midnight, executing immediately...") @@ -56,11 +56,11 @@ def main(): if reservation_success: return True - if RESOURCE_ID: - resource_id = RESOURCE_ID - reservation_success = booking.reserve(resource_id, start, end) - if reservation_success: - return True + # if 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: diff --git a/resource_id_helper.py b/resource_id_helper.py index f8e9055..471788e 100644 --- a/resource_id_helper.py +++ b/resource_id_helper.py @@ -1,8 +1,24 @@ import json -with open("nice.json", "r", encoding="utf-8") as f: +with open("data.json", "r", encoding="utf-8") as f: data = json.load(f) +keys_to_keep = {"name"} +keys_to_keep2 = {"attributes", "id"} for i in data["data"]: - print("%-32s id: %s" % (i["attributes"]["name"], i["id"])) -print(type(data)) # usually + attr = i["attributes"] + for key in list(attr.keys()): + if key not in keys_to_keep: + del attr[key] + for key in list(i.keys()): + if key not in keys_to_keep2: + del i[key] + # i["attributes"].pop("description", None) # safe remove + # i["attributes"].pop("plain_description", None) # safe remove + +with open("data.json", "w") as f: + json.dump(data, f, indent=2) + +# for i in data["data"]: +# print("%-32s id: %s" % (i["attributes"]["name"], i["id"])) +# print(type(data)) # usually