Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions examples/sdk/get_deployment_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@

def get_step_size(start_time_in_seconds: int, end_time_in_seconds: int) -> int:
time_delta_in_seconds = end_time_in_seconds - start_time_in_seconds
if time_delta_in_seconds <= 3 * HOUR_IN_SECONDS:
return 15
elif time_delta_in_seconds <= 6 * HOUR_IN_SECONDS:
return 30
elif time_delta_in_seconds <= 12 * HOUR_IN_SECONDS:
# 0 seconds to 2 days: 60s
if time_delta_in_seconds <= 2 * DAY_IN_SECONDS:
return 60
elif time_delta_in_seconds <= 24 * HOUR_IN_SECONDS:
return 2 * 60
elif time_delta_in_seconds <= 2 * DAY_IN_SECONDS:
return 2 * 60
# 2 days to 7 days: 5m
elif time_delta_in_seconds <= 7 * DAY_IN_SECONDS:
return 5 * 60
# 7 days to 14 days: 10m
elif time_delta_in_seconds <= 14 * DAY_IN_SECONDS:
return 10 * 60
elif time_delta_in_seconds <= 15 * DAY_IN_SECONDS:
return 30 * 60
# 14 days to 30 days: 30m
elif time_delta_in_seconds <= 30 * DAY_IN_SECONDS:
return 60 * 60
return math.ceil(time_delta_in_seconds / MAX_DATA_POINTS)

return 30 * 60
# 30 days to 60 days: 1 hour
elif time_delta_in_seconds <= 60 * DAY_IN_SECONDS:
return HOUR_IN_SECONDS
# 60 days to 90 days: 2 hours
elif time_delta_in_seconds <= 90 * DAY_IN_SECONDS:
return 2 * HOUR_IN_SECONDS
# 90+ days: 3 hours (This catches all ranges greater than 90 days)
else:
return 3 * HOUR_IN_SECONDS

def main():
with get_centml_client() as cclient:
Expand Down
Loading