Currently present in main people.json for about 230 memberships.
Generally I think the rule is these shouldn't happen - and could be added as a test (and fixed).
here is now twfy-votes-django is now sorting this:
def adjust_overlapping_time_ranges(popolo: Popolo, quiet: bool = False) -> Popolo:
"""
Calculating down the line depend on consecutive time ranges rather than an overlap on the end date
Ideally addressed at source.
"""
count = 0
for person in popolo.persons:
person = person.self_or_redirect()
memberships = person.memberships()
memberships.sort(key=lambda m: m.start_date)
for i, membership in enumerate(memberships[:-1]):
next_membership = memberships[i + 1]
if membership.end_date == next_membership.start_date:
if membership.organization_id != next_membership.organization_id:
continue
membership.end_date = membership.end_date - datetime.timedelta(days=1) # type: ignore
count += 1
if not quiet:
rich.print(f"Adjusted [blue]{count}[/blue] overlapping time ranges")
return popolo
The org_id bit there isn't actually right - for what we want it should also check the post__org_id - but there's no actual error in doing it this way (just to be sure if validaoting future errors).
Currently present in main people.json for about 230 memberships.
Generally I think the rule is these shouldn't happen - and could be added as a test (and fixed).
here is now twfy-votes-django is now sorting this:
The org_id bit there isn't actually right - for what we want it should also check the post__org_id - but there's no actual error in doing it this way (just to be sure if validaoting future errors).