diff --git a/crates/izlek-web/src/i18n.rs b/crates/izlek-web/src/i18n.rs index cc09ad6..43a5496 100644 --- a/crates/izlek-web/src/i18n.rs +++ b/crates/izlek-web/src/i18n.rs @@ -245,6 +245,8 @@ pub enum Key { NoDecisionsYet, NothingYet, NoRetry, + NextTry, + DueNow, Older, Newer, QueueStatePending, @@ -759,6 +761,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (NothingYet, Tr) => "Henüz bir şey yok.", (NoRetry, En) => "no retry", (NoRetry, Tr) => "yeniden denenmeyecek", + (NextTry, En) => "next try", + (NextTry, Tr) => "sonraki deneme", + (DueNow, En) => "due", + (DueNow, Tr) => "sırada", (Older, En) => "Older", (Older, Tr) => "Eski", (Newer, En) => "Newer", diff --git a/crates/izlek-web/src/logs.rs b/crates/izlek-web/src/logs.rs index 4930d26..85654f0 100644 --- a/crates/izlek-web/src/logs.rs +++ b/crates/izlek-web/src/logs.rs @@ -490,6 +490,7 @@ async fn snapshot( }; let lang = Lang::from_code(&user.language); let zone = izlek_core::detail::parse_zone(&user.timezone); + let now = OffsetDateTime::now_utc(); let store = accounts(cx).store().clone(); let mut has_more = false; @@ -549,9 +550,21 @@ async fn snapshot( state_kind: state_kind.to_string(), attempts: send.attempts, last_error: send.last_error, - next_attempt: send - .next_attempt_at - .map(|at| izlek_core::detail::moment_label_in(at, zone)), + // When the retry fires, not just a bare moment: a stamp on its + // own read as the moment the row was made. A stamp already past + // is waiting on the next sweep, so it says the sweep is owed + // rather than naming a time that has been and gone. + next_attempt: send.next_attempt_at.map(|at| { + if at <= now { + t(lang, Key::DueNow).to_string() + } else { + format!( + "{} {}", + t(lang, Key::NextTry), + izlek_core::detail::moment_label_in(at, zone) + ) + } + }), }); } diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index 54e11cd..4d7e2a2 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -6387,3 +6387,39 @@ async fn a_status_rule_may_watch_every_column() { let html = String::from_utf8_lossy(&page.bytes); assert!(html.contains("Any column"), "no any-column option: {html}"); } + +/// The queue says when a retry fires, not just a bare moment: a stamp in the +/// future is labelled as the next try, and one already past says the send is +/// due rather than naming a time that has been and gone. +#[tokio::test] +async fn the_queue_says_when_the_next_try_fires() { + let app = App::open().await; + let admin_cookie = admin(&app).await; + let (_task, send_id) = + a_task_with_a_notification(&app, &admin_cookie, "Never got there").await; + let now = time::OffsetDateTime::now_utc(); + + let later = now + time::Duration::hours(2); + app.store + .record_send_refused(&send_id, "timeout", Some(later), now) + .await + .unwrap(); + let logs = app.post("/api/current_logs", Some(&admin_cookie), &[]).await; + assert!( + logs.body.contains("next try"), + "the queue does not say when the retry fires: {}", + logs.body + ); + + // Once the moment has passed the row is waiting on the next sweep. + app.store + .record_send_refused(&send_id, "timeout", Some(now - time::Duration::hours(1)), now) + .await + .unwrap(); + let logs = app.post("/api/current_logs", Some(&admin_cookie), &[]).await; + assert!( + logs.body.contains("\"next_attempt\":\"due\""), + "a retry already owed does not say so: {}", + logs.body + ); +}