Esempio n. 1
0
 def end_ride_helper(session, city, ride_id):
     ride = session.query(Ride).filter_by(city=city, id=ride_id).first()
     v = session.query(Vehicle).filter_by(city=city, id=ride.vehicle_id).first()
     ride.end_address = v.current_location
     ride.revenue = MovRGenerator.generate_revenue()
     ride.end_time = datetime.datetime.now()
     v.status = "available"
Esempio n. 2
0
 def end_ride_helper(session, city, ride_id):
     ride = session.query(Ride).filter_by(id=ride_id)
     r = ride.first()
     vehicle = session.query(Vehicle).filter_by(id=r.vehicle_id)
     vehicle.update({'status': 'available'})
     v = vehicle.first()
     ride.update({
         'end_address': v.current_location,
         'revenue': MovRGenerator.generate_revenue(),
         'end_time': datetime.datetime.now()
     })
Esempio n. 3
0
    def add_rides_helper(sess, chunk, n):
        users = sess.query(User).filter_by(city=city).all()
        vehicles = sess.query(Vehicle).filter_by(city=city).all()

        rides = []
        for i in range(chunk, min(chunk + chunk_size, num_rides)):
            start_time = datetime.datetime.now() - datetime.timedelta(days=random.randint(0, 30))
            rides.append(Ride(id=MovRGenerator.generate_uuid(),
                              city=city,
                              rider_id=random.choice(users).id,
                              vehicle_id=random.choice(vehicles).id,
                              start_time=start_time,
                              start_address=datagen.address(),
                              end_address=datagen.address(),
                              revenue=MovRGenerator.generate_revenue(),
                              end_time=start_time + datetime.timedelta(minutes=random.randint(0, 60))))
        sess.bulk_save_objects(rides)