mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-21 07:08:20 +00:00
Revert "fix(usage): 修正 OpenAI 5h 用量百分比语义"
This reverts commit b65dde634b.
This commit is contained in:
1 parent
aa69e3947d
commit
a8ffb052ca
6 files changed
+22
-96
No files matched your search
@@ -126,19 +126,6 @@ type NormalizedCodexLimits struct {
|
||||
Window7dMinutes *int
|
||||
}
|
||||
|
||||
func normalizeCodexFiveHourUsedPercent(raw *float64) *float64 {
|
||||
if raw == nil {
|
||||
return nil
|
||||
}
|
||||
// OpenAI's 5h Codex quota header is remaining%, despite the upstream header
|
||||
// name saying "used"; the canonical codex_5h_used_percent field stores used%.
|
||||
used := 100 - *raw
|
||||
if used < 0 {
|
||||
used = 0
|
||||
}
|
||||
return &used
|
||||
}
|
||||
|
||||
// Normalize converts primary/secondary fields to canonical 5h/7d fields.
|
||||
// Strategy: Compare window_minutes to determine which is 5h vs 7d.
|
||||
// Returns nil if snapshot is nil or has no useful data.
|
||||
@@ -197,7 +184,7 @@ func (s *OpenAICodexUsageSnapshot) Normalize() *NormalizedCodexLimits {
|
||||
|
||||
// Assign values
|
||||
if use5hFromPrimary {
|
||||
result.Used5hPercent = normalizeCodexFiveHourUsedPercent(s.PrimaryUsedPercent)
|
||||
result.Used5hPercent = s.PrimaryUsedPercent
|
||||
result.Reset5hSeconds = s.PrimaryResetAfterSeconds
|
||||
result.Window5hMinutes = s.PrimaryWindowMinutes
|
||||
result.Used7dPercent = s.SecondaryUsedPercent
|
||||
@@ -207,7 +194,7 @@ func (s *OpenAICodexUsageSnapshot) Normalize() *NormalizedCodexLimits {
|
||||
result.Used7dPercent = s.PrimaryUsedPercent
|
||||
result.Reset7dSeconds = s.PrimaryResetAfterSeconds
|
||||
result.Window7dMinutes = s.PrimaryWindowMinutes
|
||||
result.Used5hPercent = normalizeCodexFiveHourUsedPercent(s.SecondaryUsedPercent)
|
||||
result.Used5hPercent = s.SecondaryUsedPercent
|
||||
result.Reset5hSeconds = s.SecondaryResetAfterSeconds
|
||||
result.Window5hMinutes = s.SecondaryWindowMinutes
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user