conversions web4

This commit is contained in:
Filipriec
2026-08-24 10:36:13 +02:00
parent fbe05feed2
commit 6784969081
11 changed files with 92 additions and 227 deletions

View File

@@ -61,7 +61,6 @@ pub(crate) async fn load_ecb_page(
Ok(EcbPageState {
nav: crate::ui::Nav::from_authorization(headers, "ecb", &authorization),
verified_through_date: status.verified_through_date,
latest_verifiable_date: status.latest_verifiable_date,
healthy: status.healthy,
days_behind: status.days_behind,
import_running: status.import_running,

View File

@@ -147,7 +147,6 @@ impl ImportBatchView {
pub(crate) struct EcbPageState {
pub nav: crate::ui::Nav,
pub verified_through_date: Option<String>,
pub latest_verifiable_date: String,
pub healthy: bool,
pub days_behind: i32,
pub import_running: bool,
@@ -188,24 +187,6 @@ impl EcbPageState {
}
}
/// The "3 publication days behind" tag in the coverage row.
pub(crate) fn behind_label(&self) -> String {
tr!(
self.nav.locale,
"ecb-behind-count",
"count" => self.days_behind as i64,
)
}
/// "2 failed" above the attempts table.
pub(crate) fn failed_count_label(&self) -> String {
tr!(
self.nav.locale,
"ecb-failed-count",
"count" => self.failure_count() as i64,
)
}
/// The class the status card is painted with.
pub(crate) fn health_class(&self) -> &'static str {
if self.healthy { "healthy" } else { "unhealthy" }
@@ -230,17 +211,6 @@ impl EcbPageState {
}
}
/// The newest attempt of any outcome, which is what "has the importer run
/// at all lately" asks about.
pub(crate) fn last_attempt(&self) -> Option<String> {
let batch = self.batches.first()?;
let when = batch.completed_at.as_deref().unwrap_or(&batch.started_at);
Some(match from_now(self.nav.locale, when) {
Some(relative) => format!("{} ({relative})", moment(when)),
None => moment(when),
})
}
/// Successes are what move coverage; a run of failures on top of an old
/// success is a different picture from no runs at all.
pub(crate) fn last_success(&self) -> Option<String> {
@@ -252,13 +222,6 @@ impl EcbPageState {
})
}
/// Failures among the attempts on the page. One is an incident; several in
/// a row is a broken pipeline, and the count is the only thing that
/// distinguishes them at a glance.
pub(crate) fn failure_count(&self) -> usize {
self.batches.iter().filter(|batch| batch.failed()).count()
}
/// Alphabetical, because the reader is looking one up rather than reading
/// the list through.
pub(crate) fn currencies(&self) -> Vec<String> {

View File

@@ -83,7 +83,6 @@ mod tests {
EcbPageState {
nav: Nav::default(),
verified_through_date: Some("2026-08-12".to_string()),
latest_verifiable_date: "2026-08-12".to_string(),
healthy: true,
days_behind: 0,
import_running: false,
@@ -102,7 +101,7 @@ mod tests {
let html = render_page(&healthy_page());
assert!(!html.contains("Template error"), "{html}");
assert!(html.contains("Rates are current"));
assert!(html.contains("Foreign-currency posting is available"));
assert!(html.contains("healthy"));
assert!(html.contains("2026-08-12"));
assert!(html.contains("CZK"));
@@ -120,10 +119,9 @@ mod tests {
let html = render_page(&page);
assert!(!html.contains("Template error"), "{html}");
assert!(html.contains("Rates are behind"));
assert!(html.contains("Some foreign-currency records may be blocked"));
assert!(html.contains("unhealthy"));
assert!(html.contains("3 publication days are missing"));
assert!(html.contains("3 publication days behind"));
}
/// Timestamps arrive as RFC 3339 instants and must not reach the page that
@@ -140,17 +138,19 @@ mod tests {
assert!(html.contains("4s"));
}
/// The counts above the table are how a run of bad days is told apart from
/// one bad day without reading every row.
/// Historical failures are troubleshooting detail, not a contradictory
/// headline beside a healthy current status.
#[test]
fn failed_attempts_are_counted_above_the_table() {
fn historical_failures_are_collapsed_as_technical_history() {
let mut page = healthy_page();
page.batches.push(batch(8, "failed"));
page.batches.push(batch(7, "failed"));
let html = render_page(&page);
assert!(html.contains("2 failed"), "{html}");
assert!(html.contains("Technical update history"), "{html}");
assert!(html.contains("<details class=\"panel\">"), "{html}");
assert!(!html.contains("2 failed"), "{html}");
}
/// Coverage is a publication date; the reader's question is which dates
@@ -160,12 +160,12 @@ mod tests {
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("Accepted transaction dates"), "{html}");
assert!(html.contains("Regular transactions"));
assert!(html.contains("<strong>2026-08-13</strong>"), "{html}");
// Askama escapes `&` numerically. The title now comes from the
// catalogue as plain text, where it was pre-escaped markup before.
assert!(html.contains("Statements &#38; decisive dates"), "{html}");
assert!(html.contains("Statements and dated balances"), "{html}");
assert!(html.contains("<strong>2026-08-12</strong>"), "{html}");
}
@@ -184,8 +184,8 @@ mod tests {
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"));
assert!(html.contains("Foreign-currency posting is unavailable"));
assert!(html.contains("Foreign-currency records cannot be posted"));
// And the postable block says so too rather than showing an empty date.
assert!(html.contains("<strong>Nothing.</strong>"), "{html}");
}

View File

@@ -53,7 +53,6 @@ mod tests {
EcbPageState {
nav: Nav::default(),
verified_through_date: Some("2026-08-23".to_string()),
latest_verifiable_date: "2026-08-23".to_string(),
healthy: true,
days_behind: 0,
import_running: false,
@@ -115,7 +114,10 @@ mod tests {
assert!(!html.contains("Template error"), "{html}");
assert!(html.contains("Profile configuration"), "{html}");
assert!(html.contains("Evidence lookup"), "{html}");
assert!(html.contains("Provider health"), "{html}");
assert!(
html.contains("Can foreign-currency records be posted?"),
"{html}"
);
assert!(html.contains("CZK"), "{html}");
assert!(html.contains("ecb"), "{html}");
assert!(html.contains("Ready"), "{html}");