mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 11:19:50 +08:00
refactor: 抽离 AI pipeline 与调度共享能力逻辑
This commit is contained in:
@@ -177,7 +177,7 @@ pub(crate) async fn build_admin_providers_summary_payload(
|
||||
.is_active
|
||||
.cmp(&left.is_active)
|
||||
.then_with(|| left.provider_priority.cmp(&right.provider_priority))
|
||||
.then_with(|| left.created_at_unix_secs.cmp(&right.created_at_unix_secs))
|
||||
.then_with(|| left.created_at_unix_ms.cmp(&right.created_at_unix_ms))
|
||||
});
|
||||
|
||||
let total = providers.len();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::handlers::admin::request::AdminAppState;
|
||||
use crate::handlers::admin::shared::unix_secs_to_rfc3339;
|
||||
use crate::handlers::public::{request_candidate_event_unix_secs, request_candidate_status_label};
|
||||
use crate::handlers::public::{request_candidate_event_unix_ms, request_candidate_status_label};
|
||||
use crate::handlers::shared::unix_ms_to_rfc3339;
|
||||
use aether_data_contracts::repository::candidates::{
|
||||
RequestCandidateStatus, StoredRequestCandidate,
|
||||
};
|
||||
@@ -82,14 +83,14 @@ pub(crate) async fn build_admin_provider_health_monitor_payload(
|
||||
for candidates in attempts_by_endpoint.values_mut() {
|
||||
candidates.sort_by(|left, right| {
|
||||
right
|
||||
.created_at_unix_secs
|
||||
.cmp(&left.created_at_unix_secs)
|
||||
.created_at_unix_ms
|
||||
.cmp(&left.created_at_unix_ms)
|
||||
.then_with(|| right.id.cmp(&left.id))
|
||||
});
|
||||
candidates.truncate(per_endpoint_limit);
|
||||
candidates.sort_by(|left, right| {
|
||||
request_candidate_event_unix_secs(left)
|
||||
.cmp(&request_candidate_event_unix_secs(right))
|
||||
request_candidate_event_unix_ms(left)
|
||||
.cmp(&request_candidate_event_unix_ms(right))
|
||||
.then_with(|| left.id.cmp(&right.id))
|
||||
});
|
||||
}
|
||||
@@ -118,12 +119,12 @@ pub(crate) async fn build_admin_provider_health_monitor_payload(
|
||||
};
|
||||
let last_event_at = candidates
|
||||
.last()
|
||||
.and_then(|candidate| unix_secs_to_rfc3339(request_candidate_event_unix_secs(candidate)));
|
||||
.and_then(|candidate| unix_ms_to_rfc3339(request_candidate_event_unix_ms(candidate)));
|
||||
let events = candidates
|
||||
.into_iter()
|
||||
.filter_map(|candidate| {
|
||||
Some(json!({
|
||||
"timestamp": unix_secs_to_rfc3339(request_candidate_event_unix_secs(&candidate))?,
|
||||
"timestamp": unix_ms_to_rfc3339(request_candidate_event_unix_ms(&candidate))?,
|
||||
"status": request_candidate_status_label(candidate.status),
|
||||
"status_code": candidate.status_code,
|
||||
"latency_ms": candidate.latency_ms,
|
||||
|
||||
@@ -88,7 +88,7 @@ pub(crate) async fn build_admin_providers_payload(
|
||||
"api_key": has_any_key_by_provider.contains(&provider_id).then_some("***"),
|
||||
"priority": provider.provider_priority,
|
||||
"is_active": provider.is_active,
|
||||
"created_at": provider.created_at_unix_secs.and_then(unix_secs_to_rfc3339),
|
||||
"created_at": provider.created_at_unix_ms.and_then(unix_secs_to_rfc3339),
|
||||
"updated_at": provider.updated_at_unix_secs.and_then(unix_secs_to_rfc3339),
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::handlers::admin::shared::unix_secs_to_rfc3339;
|
||||
use crate::handlers::public::{
|
||||
provider_key_api_formats, request_candidate_event_unix_secs, request_candidate_status_label,
|
||||
provider_key_api_formats, request_candidate_event_unix_ms, request_candidate_status_label,
|
||||
};
|
||||
use aether_data_contracts::repository::candidates::{
|
||||
RequestCandidateStatus, StoredRequestCandidate,
|
||||
@@ -172,7 +172,7 @@ pub(crate) fn build_admin_provider_summary_value(
|
||||
"endpoint_health_details": endpoint_health_details,
|
||||
"ops_configured": ops_configured,
|
||||
"ops_architecture_id": ops_architecture_id,
|
||||
"created_at": endpoint_timestamp_or_now(provider.created_at_unix_secs, now_unix_secs),
|
||||
"created_at": endpoint_timestamp_or_now(provider.created_at_unix_ms, now_unix_secs),
|
||||
"updated_at": endpoint_timestamp_or_now(provider.updated_at_unix_secs, now_unix_secs),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user