feat(analysis): _detect_gaps su timestamp consecutivi (> 20 min)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -124,3 +124,19 @@ def _expected_ticks(since: datetime, until: datetime) -> int:
|
||||
# aligned multiples and would mis-count non-aligned spans.
|
||||
span_seconds = (until - first_tick).total_seconds()
|
||||
return math.ceil(span_seconds / (_TICK_INTERVAL_MIN * 60))
|
||||
|
||||
|
||||
def _detect_gaps(timestamps: list[datetime]) -> tuple[GapRecord, ...]:
|
||||
"""Return gaps where consecutive timestamps differ by > threshold."""
|
||||
out: list[GapRecord] = []
|
||||
for prev, nxt in zip(timestamps, timestamps[1:], strict=False):
|
||||
delta_min = int((nxt - prev).total_seconds() // 60)
|
||||
if delta_min > _GAP_THRESHOLD_MIN:
|
||||
out.append(
|
||||
GapRecord(
|
||||
prev_timestamp=prev,
|
||||
next_timestamp=nxt,
|
||||
gap_minutes=delta_min,
|
||||
)
|
||||
)
|
||||
return tuple(out)
|
||||
|
||||
Reference in New Issue
Block a user