Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tijl/ /rc calendar #431

Merged
merged 160 commits into from
Jan 22, 2024
Merged

Tijl/ /rc calendar #431

merged 160 commits into from
Jan 22, 2024

Conversation

tijlleenders
Copy link
Owner

@tijlleenders tijlleenders commented Jan 6, 2024

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.

@tijlleenders
Copy link
Owner Author

tijlleenders commented Jan 16, 2024

@thinkrapido @kobe-reygel

Hey people,
Just an update on the rc-scheduler approach.

The min/max day & week budgets are working fine now!

  1. 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.

  2. 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.

  3. I've ignored clippy so far. That's another thing.

  4. 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.

@tijlleenders tijlleenders merged commit 83e7d01 into main Jan 22, 2024
3 checks passed
@tijlleenders tijlleenders deleted the tijl/-/rc-calendar branch January 22, 2024 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants