ecb for dashboard - WRONG NEEDS CORRECTION ASAP

This commit is contained in:
Priec
2026-08-13 10:20:04 +02:00
parent 78d72b7a44
commit 8f8b5b4601
10 changed files with 100 additions and 3 deletions

View File

@@ -69,6 +69,8 @@ pub(crate) async fn load_ecb_page(
import_running: status.import_running,
next_import_at: status.next_import_at,
covered_currencies: status.covered_currencies,
transactions_postable_through: status.transactions_postable_through,
statements_postable_through: status.statements_postable_through,
batches: status
.batches
.into_iter()

View File

@@ -37,8 +37,12 @@ fn coarse(duration: SignedDuration) -> String {
format!("{hours}h {minutes}m")
} else if minutes > 0 {
format!("{minutes}m {}s", seconds % 60)
} else {
} else if seconds > 0 {
format!("{seconds}s")
} else {
// A run that finished inside the same second is fast, not instant, and
// "0s" reads like a missing measurement.
"<1s".to_string()
}
}
@@ -133,6 +137,8 @@ pub(crate) struct EcbPageState {
pub next_import_at: String,
pub batches: Vec<ImportBatchView>,
pub covered_currencies: Vec<String>,
pub transactions_postable_through: Option<String>,
pub statements_postable_through: Option<String>,
}
impl EcbPageState {

View File

@@ -70,6 +70,8 @@ mod tests {
next_import_at: "2026-08-13T15:00:00Z".to_string(),
batches: vec![batch(9, "succeeded")],
covered_currencies: vec!["CZK".to_string(), "USD".to_string()],
transactions_postable_through: Some("2026-08-13".to_string()),
statements_postable_through: Some("2026-08-12".to_string()),
}
}
@@ -131,6 +133,20 @@ mod tests {
assert!(html.contains("2 failed"), "{html}");
}
/// Coverage is a publication date; the reader's question is which dates
/// they may post. The card has to answer the second one outright, and the
/// two bounds differ because the two rules differ.
#[test]
fn the_card_says_which_dates_can_be_posted() {
let html = render_page(&healthy_page());
assert!(html.contains("What can be posted right now"), "{html}");
assert!(html.contains("Ordinary transactions"));
assert!(html.contains("<strong>2026-08-13</strong>"), "{html}");
assert!(html.contains("Statements &amp; decisive dates"));
assert!(html.contains("<strong>2026-08-12</strong>"), "{html}");
}
/// A pipeline that has never succeeded is a different problem from one
/// that has fallen behind, and reads differently.
#[test]
@@ -140,12 +156,16 @@ mod tests {
page.verified_through_date = None;
page.covered_currencies.clear();
page.batches.clear();
page.transactions_postable_through = None;
page.statements_postable_through = None;
let html = render_page(&page);
assert!(!html.contains("Template error"), "{html}");
assert!(html.contains("No rates have ever been imported"));
assert!(html.contains("every conversion in a foreign currency is refused"));
// And the postable block says so too rather than showing an empty date.
assert!(html.contains("<strong>Nothing.</strong>"), "{html}");
}
/// While a batch runs the card watches itself, and the fragment it swaps