diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9da464d..bd28fe3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,15 +10,7 @@ - - - - - - - - - + @@ -254,7 +254,8 @@ - diff --git a/bookkeeper/src/main.rs b/bookkeeper/src/main.rs index c5182f5..94c3233 100644 --- a/bookkeeper/src/main.rs +++ b/bookkeeper/src/main.rs @@ -57,15 +57,20 @@ impl sea_orm_rocket::Pool for SeaOrmPool { } } -#[get("/?")] -async fn index(conn: Connection<'_, Db>, last: Option) -> Template { +#[get("/?&")] +async fn index(conn: Connection<'_, Db>, last: Option, name: Option<&str>) -> Template { let mut partial = TE::find(); if let Some(last) = last { partial = partial.filter(transaction::Column::Date.gte(Local::now() - TimeDelta::days(last as i64))); } + if let Some(name) = name { + partial = partial.filter(transaction::Column::Name.eq(name)); + } + let rows: Vec = partial + .order_by_desc(transaction::Column::Date) .order_by_desc(transaction::Column::Id) .all(conn.into_inner()) .await diff --git a/bookkeeper/templates/index.html.j2 b/bookkeeper/templates/index.html.j2 index fb8bebe..0c627ef 100644 --- a/bookkeeper/templates/index.html.j2 +++ b/bookkeeper/templates/index.html.j2 @@ -27,7 +27,7 @@ {% if loop.index == 1 %} {{ r.code|string|padLeft(6) }} - {{ r.name }} + {{ r.name }} {{ r.date }} {{ r.buy|float|round(4) }} {{ r.volume }} @@ -64,7 +64,7 @@ {% else %} {{ r.code|string|padLeft(6) }} - {{ r.name }} + {{ r.name }} {{ r.date }} {{ r.buy|float|round(4) }} {{ r.volume }}