mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
chore: omit deprecated python quota changes
This commit is contained in:
@@ -6,10 +6,9 @@ pub(crate) use crate::handlers::admin::{
|
||||
refresh_antigravity_provider_quota_locally, refresh_chatgpt_web_provider_quota_locally,
|
||||
refresh_codex_provider_quota_locally, refresh_kiro_provider_quota_locally,
|
||||
refresh_provider_oauth_account_state_after_update, update_existing_provider_oauth_catalog_key,
|
||||
AdminAppState,
|
||||
AdminGatewayProviderTransportSnapshot, AdminLocalOAuthRefreshError, AdminRequestContext,
|
||||
AdminRouteRequest, AdminRouteResponse, AdminRouteResult, AdminStatsTimeRange,
|
||||
AdminStatsUsageFilter,
|
||||
AdminAppState, AdminGatewayProviderTransportSnapshot, AdminLocalOAuthRefreshError,
|
||||
AdminRequestContext, AdminRouteRequest, AdminRouteResponse, AdminRouteResult,
|
||||
AdminStatsTimeRange, AdminStatsUsageFilter,
|
||||
};
|
||||
|
||||
use crate::handlers::admin::{
|
||||
|
||||
@@ -99,7 +99,9 @@ fn build_chatgpt_web_quota_headers(
|
||||
headers
|
||||
}
|
||||
|
||||
fn chatgpt_web_auth_config(transport: &AdminGatewayProviderTransportSnapshot) -> Option<serde_json::Value> {
|
||||
fn chatgpt_web_auth_config(
|
||||
transport: &AdminGatewayProviderTransportSnapshot,
|
||||
) -> Option<serde_json::Value> {
|
||||
transport
|
||||
.key
|
||||
.decrypted_auth_config
|
||||
@@ -205,17 +207,15 @@ fn normalize_chatgpt_web_image_quota_limit(
|
||||
};
|
||||
|
||||
let remaining = chatgpt_web_json_number(object.get("image_quota_remaining"));
|
||||
let explicit_limit = chatgpt_web_json_number(object.get("image_quota_total"))
|
||||
.filter(|value| *value > 0.0);
|
||||
let explicit_limit =
|
||||
chatgpt_web_json_number(object.get("image_quota_total")).filter(|value| *value > 0.0);
|
||||
let plan_type = chatgpt_web_json_string(object.get("plan_type"));
|
||||
let is_free_plan = plan_type
|
||||
.is_some_and(|value| value.trim().eq_ignore_ascii_case("free"));
|
||||
let is_free_plan = plan_type.is_some_and(|value| value.trim().eq_ignore_ascii_case("free"));
|
||||
let limit = if is_free_plan {
|
||||
Some(CHATGPT_WEB_FREE_IMAGE_QUOTA_LIMIT)
|
||||
} else {
|
||||
explicit_limit.or_else(|| {
|
||||
infer_chatgpt_web_image_quota_limit(plan_type, remaining, existing_limit)
|
||||
})
|
||||
explicit_limit
|
||||
.or_else(|| infer_chatgpt_web_image_quota_limit(plan_type, remaining, existing_limit))
|
||||
};
|
||||
|
||||
if let Some(limit) = limit {
|
||||
@@ -397,8 +397,10 @@ pub(crate) async fn refresh_chatgpt_web_provider_quota_locally(
|
||||
.map(|duration| duration.as_secs())
|
||||
.unwrap_or(0);
|
||||
let mut metadata_update = None::<serde_json::Value>;
|
||||
let (mut oauth_invalid_at_unix_secs, mut oauth_invalid_reason) =
|
||||
(key.oauth_invalid_at_unix_secs, key.oauth_invalid_reason.clone());
|
||||
let (mut oauth_invalid_at_unix_secs, mut oauth_invalid_reason) = (
|
||||
key.oauth_invalid_at_unix_secs,
|
||||
key.oauth_invalid_reason.clone(),
|
||||
);
|
||||
let mut status = "error".to_string();
|
||||
let mut message = None::<String>;
|
||||
|
||||
|
||||
@@ -851,9 +851,12 @@ fn build_chatgpt_web_quota_status_snapshot(
|
||||
let used = metadata
|
||||
.get("image_quota_used")
|
||||
.and_then(admin_provider_quota_pure::coerce_json_f64)
|
||||
.or_else(|| limit.zip(remaining).map(|(limit, remaining)| (limit - remaining).max(0.0)));
|
||||
let reset_at =
|
||||
provider_quota_timestamp_unix_secs(metadata.get("image_quota_reset_at"));
|
||||
.or_else(|| {
|
||||
limit
|
||||
.zip(remaining)
|
||||
.map(|(limit, remaining)| (limit - remaining).max(0.0))
|
||||
});
|
||||
let reset_at = provider_quota_timestamp_unix_secs(metadata.get("image_quota_reset_at"));
|
||||
let reset_seconds = quota_window_reset_seconds(observed_at_unix_secs, reset_at);
|
||||
let plan_type = metadata
|
||||
.get("plan_type")
|
||||
@@ -865,9 +868,9 @@ fn build_chatgpt_web_quota_status_snapshot(
|
||||
.get("image_quota_blocked")
|
||||
.and_then(admin_provider_quota_pure::coerce_json_bool)
|
||||
== Some(true);
|
||||
let usage_ratio = used.zip(limit).and_then(|(used, limit)| {
|
||||
(limit > 0.0).then_some((used / limit).clamp(0.0, 1.0))
|
||||
});
|
||||
let usage_ratio = used
|
||||
.zip(limit)
|
||||
.and_then(|(used, limit)| (limit > 0.0).then_some((used / limit).clamp(0.0, 1.0)));
|
||||
let remaining_ratio = remaining.zip(limit).and_then(|(remaining, limit)| {
|
||||
(limit > 0.0).then_some((remaining / limit).clamp(0.0, 1.0))
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user