def station_snapshot(request, station_id):
    lib_ng = True
    memcache.set(str(station_id), "", namespace=WORKSTATION_SNAPSHOTS_NS)
    station = Station.by_id(station_id)
    return render_to_response("station_snapshot.html",
                              locals(),
                              context_instance=RequestContext(request))
def station_snapshot_update(request, station_id):
    from ordering.station_connection_manager import _do_push
    station = Station.by_id(station_id)
    # send push
    ws = station.work_stations.filter(accept_shared_rides=True)[0]
    if ws:
        _do_push(ws, {"action": "get_snapshot"})

    return HttpResponse("OK")
def station_snapshot_update(request, station_id):
    from ordering.station_connection_manager import _do_push
    station = Station.by_id(station_id)
    # send push
    ws = station.work_stations.filter(accept_shared_rides=True)[0]
    if ws:
        _do_push(ws, {"action": "get_snapshot"})

    return HttpResponse("OK")
def manual_assign_ride(request):
    from sharing.sharing_dispatcher import assign_ride

    ride_id = request.POST.get("ride_id")
    station_id = request.POST.get("station_id")
    ride = SharedRide.by_id(ride_id)
    station = Station.by_id(station_id)
    if station and ride.station != station:
        fleet_manager.cancel_ride(ride)
        assign_ride(ride, station)

    return JSONResponse({'ride': ride.serialize_for_eagle_eye()})
def manual_assign_ride(request):
    from sharing.sharing_dispatcher import assign_ride

    ride_id = request.POST.get("ride_id")
    station_id = request.POST.get("station_id")
    ride = SharedRide.by_id(ride_id)
    station = Station.by_id(station_id)
    if station and ride.station != station:
        fleet_manager.cancel_ride(ride)
        assign_ride(ride, station)

    return JSONResponse({'ride': ride.serialize_for_eagle_eye()})
Beispiel #6
0
def calc_ny_sharing(offset=0, count=0, value=0):
    batch_size = 500
    logging.info("querying shared rides %s->%s" % (offset, offset + batch_size))
    s = Station.by_id(1529226)
    shared_rides = SharedRide.objects.filter(station=s)[offset: offset + batch_size]
    for sr in shared_rides:
        count += 1
        value += sr.cost

    if shared_rides:
        deferred.defer(calc_ny_sharing, offset=offset + batch_size + 1, count=count, value=value)
    else:
        logging.info("all done, sending report")
        send_mail_as_noreply("*****@*****.**", "Shared rides data for NY", msg="count=%d, value=%f" % (count, value))
Beispiel #7
0
def calc_ny_sharing(offset=0, count=0, value=0):
    batch_size = 500
    logging.info("querying shared rides %s->%s" %
                 (offset, offset + batch_size))
    s = Station.by_id(1529226)
    shared_rides = SharedRide.objects.filter(station=s)[offset:offset +
                                                        batch_size]
    for sr in shared_rides:
        count += 1
        value += sr.cost

    if shared_rides:
        deferred.defer(calc_ny_sharing,
                       offset=offset + batch_size + 1,
                       count=count,
                       value=value)
    else:
        logging.info("all done, sending report")
        send_mail_as_noreply("*****@*****.**",
                             "Shared rides data for NY",
                             msg="count=%d, value=%f" % (count, value))
def station_snapshot(request, station_id):
    lib_ng = True
    memcache.set(str(station_id), "", namespace=WORKSTATION_SNAPSHOTS_NS)
    station = Station.by_id(station_id)
    return render_to_response("station_snapshot.html", locals(), context_instance=RequestContext(request))
Beispiel #9
0
            logging.info("station_unique_id submitted: %s" % station_unique_id)
            stations = Station.objects.filter(unique_id=station_unique_id)
            if stations:
                order.originating_station = stations[0]
                order.confining_station = stations[0]
            else:
                return error_response(
                    _("Could not send order to specified station"))

        order.save()
        order_created_signal.send(sender="order_created_signal", obj=order)

        if passenger.phone != settings.APPLE_TESTER_PHONE_NUMBER:
            order_manager.book_order_async(order)
        else:  # assign order to test station so the user will see it in his history
            order.station = Station.by_id(1713061)
            order.pickup_time = 5
            order.save()
            order.change_status(old_status=PENDING, new_status=ACCEPTED)

        log_event(EventType.ORDER_BOOKED, order=order)

        book_order_message = _(
            'An SMS with ride details will arrive shortly...')
        if order.originating_station_id:
            book_order_message = _(
                "%s is looking for a free taxi. An SMS with ride details will arrive shortly..."
            ) % order.originating_station.name

        book_order_result = {
            "status":
        if station_unique_id:
            logging.info("station_unique_id submitted: %s" % station_unique_id)
            stations = Station.objects.filter(unique_id=station_unique_id)
            if stations:
                order.originating_station = stations[0]
                order.confining_station = stations[0]
            else:
                return error_response(_("Could not send order to specified station"))

        order.save()
        order_created_signal.send(sender="order_created_signal", obj=order)

        if passenger.phone != settings.APPLE_TESTER_PHONE_NUMBER:
            order_manager.book_order_async(order)
        else:  # assign order to test station so the user will see it in his history
            order.station = Station.by_id(1713061)
            order.pickup_time = 5
            order.save()
            order.change_status(old_status=PENDING, new_status=ACCEPTED)

        log_event(EventType.ORDER_BOOKED, order=order)

        book_order_message = _("An SMS with ride details will arrive shortly...")
        if order.originating_station_id:
            book_order_message = (
                _("%s is looking for a free taxi. An SMS with ride details will arrive shortly...")
                % order.originating_station.name
            )

        book_order_result = {
            "status": "booked",