Filter by name

This commit is contained in:
wjsjwr 2025-01-07 16:41:22 +08:00
parent 41d7680920
commit 71eeee73f5
3 changed files with 22 additions and 16 deletions

View File

@ -10,15 +10,7 @@
<cargoProject FILE="$PROJECT_DIR$/bookkeeper/Cargo.toml" />
</component>
<component name="ChangeListManager">
<list default="true" id="76b3b902-7a5c-4bcd-9c1b-8241d748fb44" name="更改" comment="Release first version">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/migration/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/migration/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/migration/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/migration/src/lib.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/src/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" afterDir="false" />
<change beforePath="$PROJECT_DIR$/bookkeeper/templates/tx.html.j2" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/templates/tx.html.j2" afterDir="false" />
</list>
<list default="true" id="76b3b902-7a5c-4bcd-9c1b-8241d748fb44" name="更改" comment="Refine gain algorithm and some UI update" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -153,7 +145,7 @@
<workItem from="1735392290940" duration="620000" />
<workItem from="1735392928494" duration="12910000" />
<workItem from="1735470376833" duration="16014000" />
<workItem from="1735553493290" duration="15888000" />
<workItem from="1735553493290" duration="16207000" />
</task>
<task id="LOCAL-00001" summary="Add bookkeeper">
<option name="closed" value="true" />
@ -227,7 +219,15 @@
<option name="project" value="LOCAL" />
<updated>1735565490274</updated>
</task>
<option name="localTasksCounter" value="10" />
<task id="LOCAL-00010" summary="Refine gain algorithm and some UI update">
<option name="closed" value="true" />
<created>1735578317009</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1735578317009</updated>
</task>
<option name="localTasksCounter" value="11" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -254,7 +254,8 @@
<MESSAGE value="Update some settings" />
<MESSAGE value="Modify Tx and Delete Tx" />
<MESSAGE value="Release first version" />
<option name="LAST_COMMIT_MESSAGE" value="Release first version" />
<MESSAGE value="Refine gain algorithm and some UI update" />
<option name="LAST_COMMIT_MESSAGE" value="Refine gain algorithm and some UI update" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />

View File

@ -57,15 +57,20 @@ impl sea_orm_rocket::Pool for SeaOrmPool {
}
}
#[get("/?<last>")]
async fn index(conn: Connection<'_, Db>, last: Option<u32>) -> Template {
#[get("/?<last>&<name>")]
async fn index(conn: Connection<'_, Db>, last: Option<u32>, 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<transaction::Model> = partial
.order_by_desc(transaction::Column::Date)
.order_by_desc(transaction::Column::Id)
.all(conn.into_inner())
.await

View File

@ -27,7 +27,7 @@
<tr>
{% if loop.index == 1 %}
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.code|string|padLeft(6) }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.name }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;"><a href="/?name={{ r.name }}">{{ r.name }}</a></td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;" class="{% if not r.is_done %}is-warning{% endif %}">{{ r.date }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.buy|float|round(4) }}</td>
<td rowspan="{{ loop.length }}" style="vertical-align: middle;">{{ r.volume }}</td>
@ -64,7 +64,7 @@
{% else %}
<tr>
<td>{{ r.code|string|padLeft(6) }}</td>
<td>{{ r.name }}</td>
<td><a href="/?name={{ r.name }}">{{ r.name }}</a></td>
<td class="is-warning">{{ r.date }}</td>
<td>{{ r.buy|float|round(4) }}</td>
<td>{{ r.volume }}</td>