bocoup / blocks-capacity-planner

An airtable block for matching supply to demand in an airtable base.
MIT License
3 stars 3 forks source link

Add the ability to repeat the previous weeks deliveries #35

Closed rmeritz closed 4 years ago

rmeritz commented 4 years ago

The feature was originally described in this issue: https://github.com/bocoup/blocks-capacity-planner/issues/5

screencapture-airtable-tblfZdlZTq3eFimLV-viwRsep3TjEKbIjuB-2020-05-11-15_49_53

Description:

Additional Thoughts about UI/Edge cases:

Other Cleanup Done:

jugglinmike commented 4 years ago

@rmeritz While experimenting with the code, I found it was creating a bunch of extra assignments in the table. They weren't visible from the Block because they were all being created for dates that preceded the interval I had selected, but I could see them in the Grid view.

The problem came from the fact that we created a "moment" instance outside of an iteration and called its subtract method inside an iteration. Unfortunately (and I mean that: state is awful) moment#subtract mutates the underlying object. For every assignment we considered, we extended the "start date" 7 days farther into the past.

The tricky part is that this only matters when you are filtering more than one assignment. So even though you wrote a test for the "ignore early dates" condition, it included just one assignment--not enough to trigger the bug.

I moved the "start date" calculation outside of the forEach predicate so that it's consistent across every iteration, and I extended the test to "prove" the correction.

Does that look right to you?

rmeritz commented 4 years ago

I moved the "start date" calculation outside of the forEach predicate so that it's consistent across every iteration, and I extended the test to "prove" the correction.

Does that look right to you?

Thanks for the through QA is looks good to me.