Change headers and struct of rate limits (#4060)

This commit is contained in:
Ahmed Ibrahim
2025-09-22 14:06:20 -07:00
committed by GitHub
parent 8bc73a2bfd
commit dd56750612
5 changed files with 39 additions and 34 deletions

View File

@@ -487,18 +487,18 @@ fn attach_item_ids(payload_json: &mut Value, original_items: &[ResponseItem]) {
fn parse_rate_limit_snapshot(headers: &HeaderMap) -> Option<RateLimitSnapshotEvent> {
let primary_used_percent = parse_header_f64(headers, "x-codex-primary-used-percent")?;
let weekly_used_percent = parse_header_f64(headers, "x-codex-protection-used-percent")?;
let primary_to_weekly_ratio_percent =
parse_header_f64(headers, "x-codex-primary-over-protection-limit-percent")?;
let secondary_used_percent = parse_header_f64(headers, "x-codex-secondary-used-percent")?;
let primary_to_secondary_ratio_percent =
parse_header_f64(headers, "x-codex-primary-over-secondary-limit-percent")?;
let primary_window_minutes = parse_header_u64(headers, "x-codex-primary-window-minutes")?;
let weekly_window_minutes = parse_header_u64(headers, "x-codex-protection-window-minutes")?;
let secondary_window_minutes = parse_header_u64(headers, "x-codex-secondary-window-minutes")?;
Some(RateLimitSnapshotEvent {
primary_used_percent,
weekly_used_percent,
primary_to_weekly_ratio_percent,
secondary_used_percent,
primary_to_secondary_ratio_percent,
primary_window_minutes,
weekly_window_minutes,
secondary_window_minutes,
})
}