Skip to content

Commit

Permalink
feat: add status to driver trips
Browse files Browse the repository at this point in the history
  • Loading branch information
G8LD committed Jan 16, 2024
1 parent 2c44558 commit f7d58d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions uniride_sme/model/dto/trip_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class TripDTO(TypedDict):
"""Trip DTO (Data Transfer Object)"""

trip_id: int
status: int
address: dict
driver_id: int
price: float
Expand Down
3 changes: 2 additions & 1 deletion uniride_sme/route/trip_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ def get_current_driver_trips():
user_id = get_jwt_identity()["id"]
available_trips = trip_service.get_driver_trips(user_id)
# We need to paginate the data
# TODO : add pagination
meta, paginated_data = create_pagination(request, available_trips)
response = jsonify({"trips": paginated_data, "meta": meta}), 200
response = jsonify({"trips": available_trips, "meta": meta}), 200
except ApiException as e:
response = jsonify(message=e.message), e.status_code
return response
Expand Down
7 changes: 4 additions & 3 deletions uniride_sme/service/trip_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def get_driver_trips(user_id):
query = """
SELECT
t_id,
t_status,
t_price,
t_timestamp_proposed,
t.t_user_id,
Expand All @@ -356,9 +357,8 @@ def get_driver_trips(user_id):
JOIN
uniride.ur_address arrival ON t.t_address_arrival_id = arrival.a_id
WHERE t_user_id = %s
AND t_status = %s
"""
values = (user_id, TripStatus.PENDING.value)
values = (user_id,)
conn = connect_pg.connect()
driver_current_trips = connect_pg.get_query(conn, query, values, True)

Expand Down Expand Up @@ -387,6 +387,7 @@ def format_get_current_driver_trips(driver_current_trips):
}
trip_dto = TripDTO(
trip_id=trip_bo.id,
status=trip_bo.status,
address=address_dtos,
driver_id=trip_bo.user_id,
proposed_date=str(trip_bo.timestamp_proposed),
Expand Down Expand Up @@ -872,7 +873,7 @@ def create_daily_trips(
date_start = datetime.strptime(date_start, "%Y-%m-%d")
date_end = datetime.strptime(date_end, "%Y-%m-%d")
validate_total_passenger_count(passenger_number)
validate_user_id(user_id)
validate_user_id(user_id)
if date_start.date() < datetime.today().date():
raise InvalidInputException("DATE_START_CANNOT_BE_LOWER_THAN_TODAY")
if date_start > date_end:
Expand Down

0 comments on commit f7d58d9

Please sign in to comment.