aboutsummaryrefslogtreecommitdiff
path: root/src/queries.rs
diff options
context:
space:
mode:
authorJoris2021-10-10 19:27:22 +0200
committerJoris2021-10-10 21:21:34 +0200
commit6e695bf7a0253b4f6d1db78fa4310616d8a1357f (patch)
treea5b9f30b74a6914336993f93504df3b42fccb933 /src/queries.rs
parent8ccd762bfc3d7da2716749d709cf5cc216882a23 (diff)
downloadbudget-6e695bf7a0253b4f6d1db78fa4310616d8a1357f.tar.gz
budget-6e695bf7a0253b4f6d1db78fa4310616d8a1357f.tar.bz2
budget-6e695bf7a0253b4f6d1db78fa4310616d8a1357f.zip
Search by name, cost and user
Diffstat (limited to 'src/queries.rs')
-rw-r--r--src/queries.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/queries.rs b/src/queries.rs
index df57bd8..f10c7a1 100644
--- a/src/queries.rs
+++ b/src/queries.rs
@@ -4,9 +4,11 @@ use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Clone)]
pub struct Payments {
pub page: Option<i64>,
- pub search: Option<String>,
+ pub name: Option<String>,
+ pub cost: Option<String>,
pub frequency: Option<Frequency>,
pub highlight: Option<i64>,
+ pub user: Option<i64>,
pub category: Option<i64>,
}
@@ -18,15 +20,6 @@ pub fn payments_url(q: Payments) -> String {
Some(p) => params.push(format!("page={}", p)),
};
- match q.search {
- Some(s) => {
- if !s.is_empty() {
- params.push(format!("search={}", s));
- }
- }
- _ => (),
- };
-
match q.frequency {
Some(Frequency::Monthly) => {
params.push("frequency=Monthly".to_string())
@@ -39,6 +32,21 @@ pub fn payments_url(q: Payments) -> String {
_ => (),
};
+ match q.name {
+ Some(str) => params.push(format!("name={}", str)),
+ _ => (),
+ };
+
+ match q.cost {
+ Some(n) => params.push(format!("cost={}", n)),
+ _ => (),
+ };
+
+ match q.user {
+ Some(id) => params.push(format!("user={}", id)),
+ _ => (),
+ };
+
match q.category {
Some(id) => params.push(format!("category={}", id)),
_ => (),