Error log, retry notice, a waiting counter that keeps counting
- generation_errors: every failed attempt (model, attempt, outcome, duration); admin Hibanapló page and GET /v1/admin/errors; kept 90 days - The waiting page counts from when the text was asked for (requested_at), not from the page load, so a reload no longer restarts it - It says when an attempt failed and is retried, and when a failed text's unit was given back; admins see the error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -212,7 +212,8 @@ async fn cleanup_removes_only_expired_data(db: PgPool) {
|
||||
("emails", 1),
|
||||
("invites", 0),
|
||||
("invitations", 0),
|
||||
("prompt_previews", 0)
|
||||
("prompt_previews", 0),
|
||||
("generation_errors", 0)
|
||||
]
|
||||
);
|
||||
let (left,): (Vec<Uuid>,) =
|
||||
@@ -533,6 +534,18 @@ mod analyses {
|
||||
let (status, attempts, ..) = row(&db, id).await;
|
||||
assert_eq!((status.as_str(), attempts), ("failed", 3));
|
||||
assert_eq!(refunds(&db, s.user).await, vec![1]);
|
||||
// every failed attempt is in the admin error log
|
||||
let log: Vec<(String, i32, String, String)> = sqlx::query_as(
|
||||
"SELECT source, attempt, outcome, model FROM generation_errors WHERE item_id = $1 ORDER BY id",
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_all(&db)
|
||||
.await
|
||||
.unwrap();
|
||||
let expected = |attempt: i32, outcome: &str| {
|
||||
("analysis".to_string(), attempt, outcome.to_string(), "test/model".to_string())
|
||||
};
|
||||
assert_eq!(log, vec![expected(1, "retry"), expected(2, "retry"), expected(3, "failed")]);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
@@ -780,6 +793,16 @@ mod analyses {
|
||||
let models: Vec<String> =
|
||||
fake.requests.lock().unwrap().iter().map(|b| b["model"].as_str().unwrap().to_string()).collect();
|
||||
assert_eq!(models, ["cheap/model", "cheap/model", "test/model"]);
|
||||
let outcomes: Vec<(String, String)> =
|
||||
sqlx::query_as("SELECT outcome, model FROM generation_errors WHERE item_id = $1 ORDER BY id")
|
||||
.bind(id)
|
||||
.fetch_all(&db)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
outcomes,
|
||||
[("retry".to_string(), "cheap/model".to_string()), ("fallback".to_string(), "cheap/model".to_string())]
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
|
||||
Reference in New Issue
Block a user