Exemplo n.º 1
0
def _add_to_orbit(r: RideRequest, o: Orbit):
    """ Description

            :type r:RideRequest:
            :param r:RideRequest:

            :type o:Orbit:
            :param o:Orbit:

            :raises:

            :rtype:
    """
    # set RideRequest's requestCompletion to true
    r.request_completion = True

    # RideRequest's orbitId no longer null and references Orbit's oId
    r.orbit_ref = o.get_firestore_ref()

    user_id = r.user_id

    # fill in ticket and insert in to orbit's userTicketPairs
    ticket = {
        "rideRequestRef": r.get_firestore_ref(),
        "userWillDrive": r.driver_status,
        "hasCheckedIn": False,
        "inChat": False,
        "pickupAddress": r.pickup_address
    }
    o.user_ticket_pairs[user_id] = ticket
    r.request_completion = True

    return
Exemplo n.º 2
0
def _drop_from_orbit(r: RideRequest, o: Orbit):
    # remove userRef from orbitRef's userTicketPairs
    # search userTicketPairs for userRef, remove userRef and corresponding ticket once done
    userIds = list(o.user_ticket_pairs.keys())
    for userId in userIds:
        if userId == r.user_id:
            o.user_ticket_pairs.pop(userId)
    r.orbit_ref = None
    r.request_completion = False
Exemplo n.º 3
0
def remove_from_orbit(r: RideRequest, o: Orbit):
    """ Removes userRef from orbitRef's userTicketPairs

    search userTicketPairs for userRef, remove userRef and corresponding ticket once done

    :param r: ride request to remove from orbit
    :param o: orbit
    :return:
    """
    userIds = list(o.user_ticket_pairs.keys())
    for userId in userIds:
        if userId == r.user_id:
            o.user_ticket_pairs.pop(userId)
    r.orbit_ref = None
    r.request_completion = False