From 3a51ead0d27a821bb9d8cb5c37abe58aa542f60e Mon Sep 17 00:00:00 2001 From: Bailey Stoodley <46545443+BaileyS03@users.noreply.github.com> Date: Thu, 30 May 2024 22:27:51 +0000 Subject: [PATCH] Fixing Demo Bugs --- application/app/tasks/matching.py | 9 +- application/app/views/routes.py | 4 +- endpoint.http | 188 +++++++++++++++++++++++++++++- 3 files changed, 195 insertions(+), 6 deletions(-) diff --git a/application/app/tasks/matching.py b/application/app/tasks/matching.py index c8fcd6d2..0fc93ba2 100644 --- a/application/app/tasks/matching.py +++ b/application/app/tasks/matching.py @@ -55,7 +55,7 @@ def run_trip_matching(new_trip_request_id) -> None: end_dist = haversine(end_point.x, end_point.y, end_point_trip.x, end_point_trip.y) - if abs(start_dist) <= willing_distance_to_travel and abs(end_dist) <= willing_distance_to_travel and new_trip_request.window_start_time <= trip.start_time and new_trip_request.window_end_time <= trip.end_time: + if abs(start_dist) <= willing_distance_to_travel and abs(end_dist) <= willing_distance_to_travel and new_trip_request.window_start_time <= trip.start_time and new_trip_request.window_end_time >= trip.start_time: trip.optional_trip_requests += "," + new_trip_request_id db.session.commit() return "Successful Match Found" @@ -70,7 +70,6 @@ def run_request_matching(contents) -> None: trip = db.session.execute(db.select(Trip).filter_by(id=contents.get("trip_id"))).scalars().first() - if trip is None: return "No successful Match Found" @@ -94,10 +93,14 @@ def run_request_matching(contents) -> None: willing_distance_to_travel = trip.distance_addition / trip.driver.car.max_available_seats start_time = trip.start_time + choices = [] if (seats_remaining): choices = distance_query(start_point.x, start_point.y, end_point.x, end_point.y, willing_distance_to_travel / 2, (2 * seats_remaining), start_time) for trip_req in choices: trip.optional_trip_requests += "," + (trip_req['id']) db.session.commit() - return "Successful Match Found" + if choices != []: + return "Successful Match Found" + else: + return "No successful Match Found" diff --git a/application/app/views/routes.py b/application/app/views/routes.py index fe336159..03dbf7db 100644 --- a/application/app/views/routes.py +++ b/application/app/views/routes.py @@ -397,8 +397,8 @@ def post(self): if len(trip_query.trip_requests) == seats: trip_query.status = TripState.MATCHED trip_query.seats_remaining = trip_query.seats_remaining - 1 - if trip_req_id in trip.optional_trip_requests["Trips"]: - trip.optional_trip_requests["Trips"].remove(trip_req_id) + #if trip_req_id in trip.optional_trip_requests: + # trip.optional_trip_requests[""].remove(trip_req_id) db.session.commit() return make_response(jsonify({"message": f"Trip {trip_request_query.passenger.user[0].name} has successfully been added to the trip."}), 200) diff --git a/endpoint.http b/endpoint.http index f33b70d9..43981a77 100644 --- a/endpoint.http +++ b/endpoint.http @@ -1,5 +1,191 @@ @baseUrl = http://localhost:8080 +### Proper Testing for the Presentation + +### Create a driver +POST {{baseUrl}}/driver/create +Content-Type: application/json + +{ + "username": "BaileyStoodley", + "password": "password", + "name": "Bailey Stoodley", + "phone_number": "1234567890", + "email": "Bailey.Stoodley@example.com", + "max_available_seats": 3, + "licence_plate": "123ABC" +} + + +## Create 3 passengers to populate the CAR + +### Create a passenger +POST {{baseUrl}}/passenger/create +Content-Type: application/json + +{ + "username": "MohamadD", + "password": "password", + "name": "Mohamad D", + "phone_number": "1234567890", + "email": "M.D@gmail.com" +} + +### Create a passenger +POST {{baseUrl}}/passenger/create +Content-Type: application/json + +{ + "username": "HenryBatt", + "password": "password", + "name": "Henry Batt", + "phone_number": "1234567890", + "email": "Henry.Batt@example.com" +} + +### Create a passenger +POST {{baseUrl}}/passenger/create +Content-Type: application/json + +{ + "username": "MattYoung", + "password": "password", + "name": "Matt Young", + "phone_number": "1234567890", + "email": "Matt.Young@example.com" +} + +### Create a passenger +POST {{baseUrl}}/passenger/create +Content-Type: application/json + +{ + "username": "CodyBurnett", + "password": "password", + "name": "Cody Burnett", + "phone_number": "1234567890", + "email": "Cody.Burnett@example.com" +} + +### Add Trip +POST {{baseUrl}}/trip/create +Content-Type: application/json + +{ + "username": "BaileyStoodley", + "start_time": "2024-05-31T07:38:56Z", + "end_time": "2024-05-31T08:00:00Z", + "start_location": {"latitude": -27.501250, "longitude": 152.995690, "address": "1 Hawken Drive, St Lucia"}, + "end_location": {"latitude": -27.465950, "longitude": 153.0294604, "address": "380 Queen Street, Brisbane"}, + "seats_remaining": 3, + "distance_addition": 200 +} + +### Add trip request +POST {{baseUrl}}/trip_request/create +Content-Type: application/json + +{ + "username": "MattYoung", + "requested_time": "2024-05-30T18:30:00Z", + "pickup_location": {"latitude": -27.4994772, "longitude": 152.9904883, "address": "31 Ruskin Street, Taringa"}, + "dropoff_location": {"latitude": -27.465950, "longitude": 153.0294604, "address": "380 Queen Street, Brisbane"}, + "pickup_window_start": "2024-05-30T18:00:00Z", + "pickup_window_end": "2024-06-01T10:00:00Z" +} + +### Add trip request +POST {{baseUrl}}/trip_request/create +Content-Type: application/json + +{ + "username": "CodyBurnett", + "requested_time": "2024-05-29T13:30:00Z", + "pickup_location": {"latitude": -27.497280, "longitude": 152.992850, "address": "10 Hiron Street, St Lucia"}, + "dropoff_location": {"latitude": -27.465950, "longitude": 153.0294604, "address": "380 Queen Street, Brisbane"}, + "pickup_window_start": "2024-05-29T18:00:00Z", + "pickup_window_end": "2024-06-05T10:00:00Z" +} + +### Add trip request +POST {{baseUrl}}/trip_request/create +Content-Type: application/json + +{ + "username": "HenryBatt", + "requested_time": "2024-05-30T18:00:00Z", + "pickup_location": {"latitude": -27.500890, "longitude": 152.992080, "address": "5 Camira Street, St Lucia"}, + "dropoff_location": {"latitude": -27.465950, "longitude": 153.0294604, "address": "380 Queen Street, Brisbane"}, + "pickup_window_start": "2024-05-30T08:00:00Z", + "pickup_window_end": "2024-06-01T08:00:00Z" +} + +### GET Check Worked? +POST {{baseUrl}}/trip/get/pending_nearby +Content-Type: application/json + +{ + "trip_id": "d15c50d0-d129-4cd3-99d1-f2367c52a19d", + "username": "BaileyStoodley" +} + +# to show the trip can get full +### Add trip request +POST {{baseUrl}}/trip_request/create +Content-Type: application/json + +{ + "username": "MohamadD", + "requested_time": "2024-05-30T13:30:00Z", + "pickup_location": {"latitude": -27.497280, "longitude": 152.992850, "address": "5 Gailey Road, Toowong"}, + "dropoff_location": {"latitude": -27.465950, "longitude": 153.0294604, "address": "380 Queen Street, Brisbane"}, + "pickup_window_start": "2024-05-29T18:00:00Z", + "pickup_window_end": "2024-06-05T10:00:00Z" +} + + +### GET NEW END POINT POSITIONING ALONG ROUTES +POST {{baseUrl}}/trip/get_route_positions +Content-Type: application/json + +{ + "trip_id": "b5d684de-6e2a-488a-a0e0-bc7ac63f12ff", + "username": "BaileyStoodley" +} + + + + +##### Stuff After Demonstration + + +### Create a passenger +POST {{baseUrl}}/passenger/create +Content-Type: application/json + +{ + "username": "CodyBurnett2", + "password": "password", + "name": "Cody Burnett2", + "phone_number": "1234567890", + "email": "Cody.Burnett2@example.com" +} + + +### Create a passenger +POST {{baseUrl}}/passenger/create +Content-Type: application/json + +{ + "username": "jDoe15", + "password": "53%32", + "name": "John Doe", + "phone_number": "1234567890", + "email": "john.doe1@example.com" +} + + + ### Create a driver POST {{baseUrl}}/driver/create Content-Type: application/json @@ -116,7 +302,7 @@ POST {{baseUrl}}/trips/get/all Content-Type: application/json { - "username": "jDoe12" + "username": "BaileyStoodley" } ### Get all PENDING trips for a user