From 8b504c3f9688b549e1ba5ac20f87c66e2e1a5b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 03:42:33 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20fix(logs):=20the=20queue=20says?= =?UTF-8?q?=20when=20the=20next=20try=20fires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The retry stamp was a bare moment with nothing saying what it was, so it read as when the row was made. It now names itself — "next try Aug 30 05:12" — and a stamp already past says "due", since that send is waiting on the next sweep rather than on a time that has been and gone. --- crates/izlek-web/src/i18n.rs | 6 ++++++ crates/izlek-web/src/logs.rs | 19 +++++++++++++++--- crates/izlek-web/tests/http.rs | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) 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 + ); +}