aboutsummaryrefslogtreecommitdiff
path: root/src/db/incomes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/incomes.rs')
-rw-r--r--src/db/incomes.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/db/incomes.rs b/src/db/incomes.rs
index 688e9e1..d33cbcb 100644
--- a/src/db/incomes.rs
+++ b/src/db/incomes.rs
@@ -5,7 +5,6 @@ use tokio_rusqlite::{named_params, Connection, Row};
use crate::db::utils;
use crate::model::income::{Create, Form, Stat, Table, Update};
-use crate::model::report::Report;
fn row_to_table(row: &Row) -> Result<Table, rusqlite::Error> {
Ok(Table {
@@ -487,63 +486,3 @@ pub async fn total_each_month(conn: &Connection) -> Vec<Stat> {
}
}
}
-
-pub async fn last_week(conn: &Connection) -> Vec<Report> {
- let query = r#"
- SELECT
- strftime('%m/%Y', incomes.date) AS date,
- users.name AS name,
- incomes.amount AS amount,
- (CASE
- WHEN
- incomes.deleted_at IS NOT NULL
- THEN
- 'Deleted'
- WHEN
- incomes.updated_at IS NOT NULL
- AND incomes.created_at < date('now', 'weekday 0', '-13 days')
- THEN
- 'Updated'
- ELSE
- 'Created'
- END) AS action
- FROM
- incomes
- INNER JOIN
- users
- ON
- incomes.user_id = users.id
- WHERE
- (
- incomes.created_at >= date('now', 'weekday 0', '-13 days')
- AND incomes.created_at < date('now', 'weekday 0', '-6 days')
- ) OR (
- incomes.updated_at >= date('now', 'weekday 0', '-13 days')
- AND incomes.updated_at < date('now', 'weekday 0', '-6 days')
- ) OR (
- incomes.deleted_at >= date('now', 'weekday 0', '-13 days')
- AND incomes.deleted_at < date('now', 'weekday 0', '-6 days')
- )
- ORDER BY
- incomes.date
- "#;
-
- let res = conn
- .call(move |conn| {
- let mut stmt = conn.prepare(query)?;
- let xs = stmt
- .query_map([], utils::row_to_report)?
- .collect::<Result<Vec<Report>, _>>()?;
-
- Ok(xs)
- })
- .await;
-
- match res {
- Ok(xs) => xs,
- Err(err) => {
- log::error!("Error listing payments for report: {:?}", err);
- vec![]
- }
- }
-}