diff --git a/swh/scheduler/journal_client.py b/swh/scheduler/journal_client.py --- a/swh/scheduler/journal_client.py +++ b/swh/scheduler/journal_client.py @@ -32,11 +32,11 @@ def from_position_offset_to_days(position_offset: int) -> int: - """Compute position offset to interval in days. + """Compute position offset to interval in days. Bounds the position_offset to 10. - index 0 and 1: interval 1 day - index 2, 3 and 4: interval 2 days - - index 5 and up: interval `4^(n-4)` days for n in (4, 16, 64, 256, 1024, ...) + - index 5 and up: interval `4^(n-4)` days for n in [1:10]. Args: position_offset: The actual position offset for a given visit stats @@ -51,7 +51,8 @@ elif position_offset < 5: result = 2 else: - result = 4 ** (position_offset - 4) + exp = min(position_offset, 10) + result = 4 ** (exp - 4) return result diff --git a/swh/scheduler/tests/test_journal_client.py b/swh/scheduler/tests/test_journal_client.py --- a/swh/scheduler/tests/test_journal_client.py +++ b/swh/scheduler/tests/test_journal_client.py @@ -838,6 +838,8 @@ (8, 256), (9, 1024), (10, 4096), + (11, 4096), + (12, 4096), ], ) def test_journal_client_from_position_offset_to_days(position_offset, interval):