mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
Exclude unknown providers from usage aggregations
This commit is contained in:
@@ -163,12 +163,19 @@ pub(super) async fn build_admin_usage_aggregation_stats_response(
|
||||
"api_format" => UsageAuditAggregationGroupBy::ApiFormat,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let exclude_reserved_provider_labels = matches!(
|
||||
group_by_query,
|
||||
UsageAuditAggregationGroupBy::Model
|
||||
| UsageAuditAggregationGroupBy::Provider
|
||||
| UsageAuditAggregationGroupBy::ApiFormat
|
||||
);
|
||||
let usage = state
|
||||
.aggregate_usage_audits(&UsageAuditAggregationQuery {
|
||||
created_from_unix_secs,
|
||||
created_until_unix_secs,
|
||||
group_by: group_by_query,
|
||||
limit,
|
||||
exclude_reserved_provider_labels,
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -780,6 +780,7 @@ async fn dashboard_load_user_counts(
|
||||
created_until_unix_secs,
|
||||
group_by: UsageAuditAggregationGroupBy::User,
|
||||
limit: 10_000,
|
||||
exclude_reserved_provider_labels: false,
|
||||
})
|
||||
.await?;
|
||||
let count = fallback.len() as u64;
|
||||
|
||||
@@ -528,8 +528,29 @@ async fn gateway_handles_admin_usage_aggregation_stats_locally_with_trusted_admi
|
||||
usage_3.endpoint_api_format = Some("claude:messages".to_string());
|
||||
usage_3.provider_api_family = Some("claude".to_string());
|
||||
|
||||
let mut unknown_usage = sample_usage_row(
|
||||
"usage-unknown",
|
||||
"req-unknown",
|
||||
Some("user-2"),
|
||||
Some("key-2"),
|
||||
Some("secondary"),
|
||||
"unknow",
|
||||
"gpt-5",
|
||||
"completed",
|
||||
900,
|
||||
300,
|
||||
9.0,
|
||||
10.8,
|
||||
DAY_2_UNIX_SECS,
|
||||
);
|
||||
unknown_usage.provider_id = None;
|
||||
unknown_usage.total_tokens = unknown_usage.input_tokens;
|
||||
|
||||
let usage_repository = Arc::new(InMemoryUsageReadRepository::seed(vec![
|
||||
usage_1, usage_2, usage_3,
|
||||
usage_1,
|
||||
usage_2,
|
||||
usage_3,
|
||||
unknown_usage,
|
||||
]));
|
||||
|
||||
let gateway = build_router_with_state(
|
||||
|
||||
Reference in New Issue
Block a user