Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into password_security_addi…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
henrybatt committed May 31, 2024
2 parents 96dfeb3 + 3a51ead commit 03480ed
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 7 deletions.
9 changes: 6 additions & 3 deletions application/app/tasks/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand All @@ -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"
5 changes: 2 additions & 3 deletions application/app/views/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,11 @@ def post(self):
trip_request_query.status = TripRequestState.MATCHED
db.session.commit()
link_trip_request_to_trip(contents.get("trip_id"), contents.get("trip_request_id"))

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)
Expand Down
188 changes: 187 additions & 1 deletion endpoint.http
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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": "[email protected]"
}

### Create a passenger
POST {{baseUrl}}/passenger/create
Content-Type: application/json

{
"username": "HenryBatt",
"password": "password",
"name": "Henry Batt",
"phone_number": "1234567890",
"email": "[email protected]"
}

### Create a passenger
POST {{baseUrl}}/passenger/create
Content-Type: application/json

{
"username": "MattYoung",
"password": "password",
"name": "Matt Young",
"phone_number": "1234567890",
"email": "[email protected]"
}

### Create a passenger
POST {{baseUrl}}/passenger/create
Content-Type: application/json

{
"username": "CodyBurnett",
"password": "password",
"name": "Cody Burnett",
"phone_number": "1234567890",
"email": "[email protected]"
}

### 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": "[email protected]"
}


### Create a passenger
POST {{baseUrl}}/passenger/create
Content-Type: application/json

{
"username": "jDoe15",
"password": "53%32",
"name": "John Doe",
"phone_number": "1234567890",
"email": "[email protected]"
}



### Create a driver
POST {{baseUrl}}/driver/create
Content-Type: application/json
Expand Down Expand Up @@ -147,7 +333,7 @@ POST {{baseUrl}}/trips/get/all
Content-Type: application/json

{
"username": "jDoe12"
"username": "BaileyStoodley"
}

### Get all PENDING trips for a user
Expand Down

0 comments on commit 03480ed

Please sign in to comment.