fix(feedback): isolate summary state failures
This commit is contained in:
@@ -1310,6 +1310,22 @@ async fn load_summary_run_by_idempotency(
|
||||
summary_run_response(pool, row).await
|
||||
}
|
||||
|
||||
async fn load_latest_summary_run(
|
||||
pool: &PgPool,
|
||||
session_id: Uuid,
|
||||
) -> Result<Option<SummaryRunResponse>, ApiError> {
|
||||
let row = sqlx::query_as::<_, SummaryRunRow>(
|
||||
"SELECT id, feedback_session_id, status, content, method, model, prompt_version, \
|
||||
character_count, error_message, attempts, created_at, completed_at, applied_at \
|
||||
FROM feedback_summary_runs WHERE feedback_session_id = $1 \
|
||||
ORDER BY created_at DESC, id DESC LIMIT 1",
|
||||
)
|
||||
.bind(session_id)
|
||||
.fetch_optional(pool)
|
||||
.await?;
|
||||
summary_run_response(pool, row).await
|
||||
}
|
||||
|
||||
async fn summary_run_response(
|
||||
pool: &PgPool,
|
||||
row: Option<SummaryRunRow>,
|
||||
@@ -1380,16 +1396,19 @@ async fn load_session_response(
|
||||
.bind(session.id)
|
||||
.fetch_all(pool)
|
||||
.await?;
|
||||
let latest_summary_run_row = sqlx::query_as::<_, SummaryRunRow>(
|
||||
"SELECT id, feedback_session_id, status, content, method, model, prompt_version, \
|
||||
character_count, error_message, attempts, created_at, completed_at, applied_at \
|
||||
FROM feedback_summary_runs WHERE feedback_session_id = $1 \
|
||||
ORDER BY created_at DESC, id DESC LIMIT 1",
|
||||
)
|
||||
.bind(session.id)
|
||||
.fetch_optional(pool)
|
||||
.await?;
|
||||
let latest_summary_run = summary_run_response(pool, latest_summary_run_row).await?;
|
||||
let latest_summary_run = match load_latest_summary_run(pool, session.id).await {
|
||||
Ok(run) => run,
|
||||
Err(error) => {
|
||||
tracing::warn!(
|
||||
event = "summary_state_load_failed",
|
||||
feedback_session_id = %session.id,
|
||||
error_class = "summary_database_query_failed",
|
||||
error = %error,
|
||||
"summary state could not be loaded; returning the feedback session without it"
|
||||
);
|
||||
None
|
||||
}
|
||||
};
|
||||
let processing_segment_count = segments
|
||||
.iter()
|
||||
.filter(|segment| segment.status == "processing")
|
||||
|
||||
Reference in New Issue
Block a user