Skip to content

Instantly share code, notes, and snippets.

@starsinmypockets
Last active March 5, 2019 14:39
Show Gist options
  • Select an option

  • Save starsinmypockets/9233d904e8f689c9fa3dc8e762dba546 to your computer and use it in GitHub Desktop.

Select an option

Save starsinmypockets/9233d904e8f689c9fa3dc8e762dba546 to your computer and use it in GitHub Desktop.
/**
* Our scheduling algorithm only shows optimistic availble gaps based on the driver's current schedule, and the current time
* As time goes on and the schedule changes, we update gaps / availability to reflect new facts, but we don't need logic for that,
* since those are inputs
**/
// Schedule:
[
// a scheduled trip
[
{ start: Date, end: Date }, // earliest possible start time - max(apptStart, now)
{ start: Date, end: Date} // latest possible start time min(nextStart, apptEnd)
],
// another trip
[
{ start: Date, end Date }
// ...
]
]
// Gaps:
// use this to show driver available runs with `Order.extemdObservable` or similar
[ { start: Date, end: Date }, { start: Date, end: Date } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment