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