aboutsummaryrefslogtreecommitdiff
path: root/server/src/Persistence
diff options
context:
space:
mode:
authorJoris2019-11-03 11:28:42 +0100
committerJoris2019-11-03 11:28:42 +0100
commit9dbb4e6f7c2f0edc1126626e2ff498144c6b9947 (patch)
treeda352e0861a2786a3a57dab2397ec7d678b5919b /server/src/Persistence
parenta267f0bb4566389342c3244d3c082dc2453f4615 (diff)
Show income header
Diffstat (limited to 'server/src/Persistence')
-rw-r--r--server/src/Persistence/Income.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/server/src/Persistence/Income.hs b/server/src/Persistence/Income.hs
index de55a18..4ae3228 100644
--- a/server/src/Persistence/Income.hs
+++ b/server/src/Persistence/Income.hs
@@ -1,7 +1,7 @@
module Persistence.Income
( count
, list
- , listv2
+ , listAll
, create
, edit
, delete
@@ -43,15 +43,8 @@ count =
SQLite.query_ conn "SELECT COUNT(*) FROM income WHERE deleted_at IS NULL"
)
-list :: Query [Income]
-list =
- Query (\conn ->
- map (\(Row i) -> i) <$>
- SQLite.query_ conn "SELECT * FROM income WHERE deleted_at IS NULL"
- )
-
-listv2 :: Int -> Int -> Query [Income]
-listv2 page perPage =
+list :: Int -> Int -> Query [Income]
+list page perPage =
Query (\conn ->
map (\(Row i) -> i) <$>
SQLite.query
@@ -60,6 +53,16 @@ listv2 page perPage =
(perPage, (page - 1) * perPage)
)
+listAll :: Query [Income]
+listAll =
+ Query (\conn ->
+ map (\(Row i) -> i) <$>
+ SQLite.query_ conn "SELECT * FROM income WHERE deleted_at IS NULL"
+ )
+
+-- firstIncomeByUser
+-- SELECT user_id, MIN(date) FROM income WHERE deleted_at IS NULL GROUP BY user_id;
+
create :: UserId -> Day -> Int -> Query Income
create userId date amount =
Query (\conn -> do