Skip to content

Commit dc14963

Browse files
committed
Fix visit duration calculations
1 parent bd1a1f8 commit dc14963

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

api/src/tasks/delegate.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,12 +1199,12 @@ def visit_events_by_member_id(
11991199
visits = []
12001200
start_of_current_visit = None
12011201

1202-
def add_visit(start: datetime, end: datetime) -> None:
1203-
duration = end - start
1202+
def add_visit(visit_start: datetime, visit_end: datetime) -> None:
1203+
duration = visit_end - visit_start
12041204
duration += DURATION_AT_SPACE_HEURISTIC # Assume some extra time after last door open
1205-
# Clamp duration to not go beyond 'end'
1206-
duration = min(start + duration, end) - start
1207-
visits.append((start, duration))
1205+
# Clamp duration to not go beyond (global) 'end'
1206+
duration = min(visit_start + duration, end) - visit_start
1207+
visits.append((visit_start, duration))
12081208

12091209
for event in events:
12101210
if last_event is None or (event.invoked_at - last_event.invoked_at) > timedelta(hours=4):
@@ -1279,9 +1279,9 @@ def score_calculation_summary(self, line_prefix: str = "", column_width: int = 0
12791279
current_score = op.value
12801280
lines.append(f"{line_prefix}= {v_str} => {current_score:.2f}")
12811281

1282-
assert (
1283-
abs(current_score - self.score) < 0.0001
1284-
), f"Score calculation mismatch: calculated {current_score}, expected {self.score}"
1282+
assert abs(current_score - self.score) < 0.0001, (
1283+
f"Score calculation mismatch: calculated {current_score}, expected {self.score}"
1284+
)
12851285
return "\n".join(lines)
12861286

12871287

0 commit comments

Comments
 (0)