bunkat / schedule

Automatically schedules tasks, work items, meetings, reservations, etc. Schedule takes into account working hours, holidays/days off, people's work schedule/vacation time, as well as task dependencies.
http://bunkat.github.io/schedule/
MIT License
429 stars 87 forks source link

dynamic scheduling #11

Open jupe opened 8 years ago

jupe commented 8 years ago

I would like to manage scheduling dynamically, so that new resources and tasks appear/disappear on the fly.

something like:

var scheduler = schedule.create(initial_tasks, initial_resources, null, start);
setInterval( function() {
     //add one more task every 1 second
    scheduler.add_task(..)
}, 1000);
setInterval( function() {
     //add one more resource every 5 second
     scheduler.add_resource()
     //remove one resource from resources pool
     scheduler.remove_resource(<id>)
}, 5000);

for(var task in scheduler.get_next_scheduled_task()) {
    ...
}

Is this already possible, and if not, how much it needs effort to implement this kind of feature ?

bunkat commented 8 years ago

Every time you call schedule.create(tasks, resources); it creates a schedule based on what is currently specified. Every time you add a resource or task, you should just reschedule everything. If you are looking for the next schedule task, you would just pick the task with the earliest start date.

If you knew more about the tasks and resources, you could just reschedule the tasks that were affected by the change that was made, but unless you are dealing with thousands of tasks, rescheduling everything every second shouldn't be a problem.