Skip to content

Django based app using GraphQL to create/edit vehicle shifts for ride share

Notifications You must be signed in to change notification settings

bardiab/shift-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vehicle Shift Manager

To run:

First, set up a postgres db instance configured with the settings defined in settings.py

Activate virtual environment and install all requirements from requirements.txt:

source venv/bin/activate
pip install -r requirements.txt 

Ensure you have the correct settings module defined by running:

export DJANGO_SETTINGS_MODULE=config.settings

Then, to run the server and open up the graphql explorer:

python manage.py runserver

You can access the API at: http://127.0.0.1:8000/api/graphql

API Guide:

  1. Convenience query to get all vehicles
query allVehicles {
  allVehicles {
    batteryLevel
    id
    inUse
    licensePlate
    locationLat
    locationLong
    model
  }
}
  1. Review all vehicles in a shift
query vis {
  vehiclesInShift(shiftId: "") {
    licensePlate
  }
}
  1. Check if a swap has been completed for any vehicle in a shift.
query swapCompleted {
  isSwapCompleted(shiftId: "", vehicleId: "")
}
  1. Check if all vehicles in the shift have had their battery swaps completed.
query shiftCompleted {
  isShiftCompleted(shiftId: "")
}
  1. Complete a battery swap for a vehicle. Note: we are assuming that we have an infinite supply of batteries charged to 100%.
mutation swapBattery {
  swapVehicleBattery(vehicleId: "") {
    batteryLevel
  }
}
  1. Create a shift
mutation createShift {
  createShift {
    id
    completed
    active
  }
}
  1. Add Vehicles to a shift
mutation addV {
  addVehiclesToShift(shiftId: "" vehicleIds: [""]) {
    swapCompleted
    id
  }
}
  1. Create a shift automatically. The suggested long lat provided correspond to a location in Dumbo, Brooklyn. Assuming that we don't want to have vehicles in the shift be more than 50 miles away from current location. Distance is represented in miles.
mutation createAutoShift {
  createAutomaticShift(long: -73.992226, lat: 40.694891) {
    vehicleShift {
      swapCompleted
    }
    batteryLevel
    licensePlate
    distance
  }
}

About

Django based app using GraphQL to create/edit vehicle shifts for ride share

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages