Skip to content

Commit

Permalink
Updated with Heathrow
Browse files Browse the repository at this point in the history
  • Loading branch information
simonottosen authored Jul 2, 2024
1 parent dfdd7bf commit b4885a9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions fetchtime/project/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,37 @@ def firebase_write(airport):

return firebase_write_status

def heathrow():
airport = "LHR"
airport_api = "https://api-dp-prod.dp.heathrow.com/pihub/securitywaittime/ByTerminal/2"
headers = {"origin": "https://www.heathrow.com"}

# Use requests module to send a GET request to the airport API and retrieve waiting time information as JSON
response = requests.get(airport_api, headers=headers)
waitingtime = json.loads(response.text)

# Loop through data in the waiting time JSON until you find the relevant security checkpoint waiting time
for entry in waitingtime:
for measurement in entry['queueMeasurements']:
if measurement['name'] == 'maximumWaitTime':
numbers = measurement['value']
if isinstance(numbers, int):
queue = numbers # Assign a value to queue
else:
print("Error: Information not found in the JSON data.")
# Get current UTC datetime and format as string
now_utc = datetime.utcnow()
timestamp = now_utc.strftime('%Y-%m-%dT%H:%M:%S')

# Call three other functions to write the retrieved waiting time data to a database, firebase, and to perform a healthcheck. Store the result of each function into corresponding variables
database_write_status = database_write(queue, timestamp, airport)
firebase_write_status = firebase_write(airport)
supabase_write_status = supabase_write(queue, timestamp, airport)
healthcheck_perform_status = healthcheck_perform(healthcheck)

# Print a completion message with the status results from the three previous function calls
print("Airport "+str(airport)+" was completed with the following status. Database: "+str(database_write_status)+". Firebase: "+str(firebase_write_status)+". Supabase: "+str(supabase_write_status)+". Healthcheck: "+str(healthcheck_perform_status)+". Queue is "+str(queue)+" at "+str(timestamp))

# This function retrieves the waiting time at Frankfurt airport
def frankfurt():
# Define initial values
Expand Down

0 comments on commit b4885a9

Please sign in to comment.