public List retrieveDriversAroundLocations()

in prototype/dispatch/order-dispatcher/src/main/java/com/aws/proto/dispatching/data/DriverQueryManager.java [55:87]


    public List<PlanningDriverBase> retrieveDriversAroundLocations(List<Coordinates> locations) {
        int countPerLocation = 3;
        if(locations.size() > 30) {
            countPerLocation = 2;
        }

        DriverQueryRequest driverQueryRequest = new DriverQueryRequest();
        driverQueryRequest.locations = locations.stream().map(c -> { return new DriverQueryRequest.LatLong(c); }).collect(Collectors.toList());
        driverQueryRequest.countPerLocation = countPerLocation;
        driverQueryRequest.distance = 500;
        driverQueryRequest.distanceUnit = "m";
        driverQueryRequest.status = "IDLE";

        List<InputDriverData> drivers = driverQueryClient.getAvailableDriversPerRestaurant(driverQueryRequest);

        if(drivers == null || drivers.size() == 0) {
            return new ArrayList<>();
        }

        List<PlanningDriverBase> planningDrivers = new ArrayList<>();
        for(InputDriverData driver : drivers) {
            DriverLocation driverLocation = new DriverLocation(driver.driverId, Coordinates.valueOf(driver.lat, driver.lon), driver.timestamp);
            PlanningDriverBase planningDriver = new PlanningDriverBase(driver.driverId, driver.driverIdentity, driverLocation, driver.status);

            planningDrivers.add(planningDriver);
        }

        logger.debug("Retrieved {} IDLE drivers - from around each restaurant", planningDrivers.size());

//        logger.warn("returning only 3 drivers");
//        return planningDrivers.stream().limit(3).collect(Collectors.toList());
        return planningDrivers;
    }