Closed tijlleenders closed 10 months ago
Oh I see I still have some Clippy things to fix... and just added a new test case for default_budgets that isn't passing yet.
@thinkrapido @kobe-reygel
Hey people, Just an update on the rc-scheduler approach.
The min/max day & week budgets are working fine now!
The only reason the default_budgets
test is failing is because I don't like the extra sleep hours (the diff between min and max) being scheduled from 22-23, with a gap from 23-0. This could be fixed easily by scheduling a min-max activity that sees previously scheduled min hours as available hours - or by having (max-min) 1h activities requiring adjacent hours are of the same goal for the overlay to show as free.
I've been quite lazy in the code. There is a lot of cleaning up to do.
Some thing are duplicated on purpose so I don't have to keep two contexts in my mind when walking through the code. I don't think it is worth factoring out with an extra argument for the context ... but there are still some opportunities for factoring out parts of functions that don't depend on the context they are called in - or moving functions to the 'appropriate' module.
I've ignored clippy so far. That's another thing.
Finally, there's a bunch of TODO's I sprinkled all over the place whenever I thought of something while working on something else.
I'll not have time to code till Friday morning - as going to the office physically consumes the little 'free/coding/ZinZen' hours I have in a day - so feel free to do stuff - if you feel like it.
After review from @thinkrapido this implementation and the abstractions seems to fit the need.
The approach is to use a main calendar of Vec<Rc>.
Each Hour on the Calendar can be Free or Occupied.
Each Goal (simple or budget) gets translated to one or more Activities by activity_generator.rs.
Each Activity has an internal calendar_overlay of Vec<Option<Weak>>.
This get filtered on Activity creation for any Hour that doesn't fit the Goal constraints.
After that, the activity_placer.rs doesn't know anything about dates/times - it just looks at how many blocks are available, and schedules each Activity in turn, counting conflicts via Rc::weak_count, updating the Calendar, which auto-updates the Activities overlay via the Rc:Weak that get invalidated when an Hour is converted from Free to Occupied.