Plan via backend
Plan TSP and VRP through the backend.
Introduction
This involves all actions to arrive at the situation where the staging area can be used for all planning and unplanning operations.
subtasks
- get ctags to work for javascript ✔
- drag drop into staging area should work for orders and vehicles ✔
- unplan selected action button ✔
- add user management to database ✔
- test program that can create random test and import for PTV + klopt ✔
- get renewal for PTV tests ✔
- plan selected action button
- unstage solution (drag into another window ?) at least unstage selected button
- plan via cheapest insert
- plan via lkh, for now with separate buttons
- option for getting all selected into staging area ✔
- request a multi-vehicle solution and distance matrix solution PTV ✔
unplan orders
A button for unplanning all selected items, both orders and vehicles in the planning stage.
We probably need a new icon with a crossed out vehicle. For now i chose for a grey truck as opposed to the black one for ‘plan selected’
Then we also want a generic way of running commands inside the backend. I suggest starting with a scheme where we generate a list of orders from json input and run a lambda function on that list.
I split the function plan_unplan_orders into plan_unplan_orders(std::map
add user management
This is a construct that is needed anyway, but at this time it can greatly aid in running automated tests as well as interface tests. For instance we want to run a clean order import for user test, but still keep the orders for kees in the interface.
How to do that best should be investigated, for now we aim at using different schemas for each user in postgresql.
It says :
Schemas allow you to organize database objects e.g., tables into logical groups to make them more manageable. Schemas enable multiple users to use one database without interfering with each other.
Indeed if we create a schema for each user, the data will be separated and you can for instance reach tables with this notation:
So there should be code for generating a new scheme for new users but also it should be coupled with the login procedure using firebase. Also every action must be checked for the correct logged in user, something like flask did.
I think it is best not to put the username into every rest call but make a login procedure with token instead. there has to be a rest endpoint for requesting the token, then the token needs to be passed in all subsequent calls. These retrieve the username from the token. There was a technique i used some time ago that is called JWT (JSON Web Tokens)
Since we already use firebase maybe this will be the way to go :
https://firebase.google.com/docs/auth/admin/create-custom-tokens
for angular, and also a good explanation :
https://blog.angular-university.io/angular-jwt/ https://blog.angular-university.io/angular-jwt-authentication/
I actually mean the second, but the first is very handy for prior knowledge.
See another task page for jwt tryouts
For now : we assume the server stays purely local (127.0.0.1:8000) and apache does the authorization, which means we can just add the header user=kees to every call and get the schema from that.
Maybe now is a good time to decide if we are going to use an id, username of email for the schema.
- id : it is unique but not exactly debug friendly
- email : unique but schema can become messy with long emails ?
- username : does not have to be unique
But the username would do better if we just not allow duplicate names, su you can use this as a schema name but also so you can login by name instead of always by email.
It is possible to make a schema name with an @ by including it with “double quotes” .
To be clearer : ONLY the schema name should be in quotes !!
CREATE TABLE "kees@klopt.org.orders"
# actually creates public.kees@klopt.org.orders
CREATE TABLE "kees@klopt.org”.orders
# creates what you want, a table in the schema, not public !
Temporary solution
We now add the email address in a “schema” header in each request. It seems not to be possible to create a schema with existing tables. But you can recreate them easy with this syntax :
test program for random plans with PTV and klopt import
Make a python script for this, that posts plans to the REST interface. see klopt/test directory for a start
get renewal PTV trials
Start with renewal of the single vehicle product. But after that and after the importer works (see last chapter) get a trial for multi-vehicle planning.
Also ask for time/distance matrix functionality (probably the on-site version)
If matrix can also be done on the web version, specifically ask for the onsite (x)server version.
plan selected button
To get things running in the interface as well, plan selected orders on selected vehicles.
unstage selected button
Or dragdrop solution (drag back to order/vehicle window maybe ?)
cheapest insert
Implement cheapest insert as base planning. It can be done linearly so fast and it provides a basis for quality comparison.
plan via LKH
todo
option for getting all selected into staging area
Hasn`t this been done already ? Test that first.
request multi vehicle planning at PTV
Mentioned before but only do this after all previous actions work !