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

Fix a case when multiple location changes doesn't result in the right due dates #803

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

PabloDinella
Copy link
Collaborator

When multiple location changes happens without a pause in the middle (when the child goes to the parent), the calculation ignores the subsequential locations and only calculates the due dates for the first location. This PR changes that so all location changes are taken into account.

Changes in code style were made by csharpier.

@@ -528,29 +519,38 @@ ImmutableList<DateOnly> completionDates

private static IEnumerable<DateRange<Guid>> GenerateDateRanges(ImmutableList<ChildLocation> childLocations)
{
DateOnly? startDate = null;
Guid? tag = null;
(DateOnly, Guid)? entry = null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use an anonymous record here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try (DateOnly myDate, Guid myId)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to previousNotPausedEntry for clarity

@@ -528,29 +519,38 @@ ImmutableList<DateOnly> completionDates

private static IEnumerable<DateRange<Guid>> GenerateDateRanges(ImmutableList<ChildLocation> childLocations)
{
DateOnly? startDate = null;
Guid? tag = null;
(DateOnly, Guid)? entry = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try (DateOnly myDate, Guid myId)?

@@ -528,29 +519,38 @@ ImmutableList<DateOnly> completionDates

private static IEnumerable<DateRange<Guid>> GenerateDateRanges(ImmutableList<ChildLocation> childLocations)
{
DateOnly? startDate = null;
Guid? tag = null;
(DateOnly, Guid)? entry = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to previousNotPausedEntry for clarity

tag = childLocation.ChildLocationFamilyId;
yield return new DateRange<Guid>(
entry.Value.Item1,
childLocation.Date.AddDays(-1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an inline comment to explain this:

When a child is cared for, the care duration is from the start date of childcare until the next entry's date of childcare minus one day.

What about a child changing location more than once in the same day, which can happen? This would be a negative date range.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 1: Add a unit test for the multiple-changes-in-one-day scenario (start w/ parent, go to volunteer, go to another volunteer, go back to the first volunteer, then go to the parent). That will introduce some fun wrinkles. 😅

}

[TestMethod]
public void CreateTimelineFilteredByFamilyIdNoPauses()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need another test to test interaction with pauses, as well.

@PabloDinella PabloDinella force-pushed the fix-multiple-location-changes branch 2 times, most recently from 448960f to a4640ea Compare December 13, 2024 23:30
@PabloDinella PabloDinella force-pushed the fix-multiple-location-changes branch from a4640ea to 8582c33 Compare December 16, 2024 14:34
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