aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model
diff options
context:
space:
mode:
authorJoris2015-09-04 09:52:20 +0200
committerJoris2015-09-04 09:52:20 +0200
commitc1f44a5890fbb26faf6f17c676662ea1bd495f2e (patch)
treef158bdef5bd985a9b11d46d12878d566268cf6cc /src/server/Model
parent889df8caf04de5f10a9e623bab3e502e9573159d (diff)
Adding paging (need some fixes)
Diffstat (limited to 'src/server/Model')
-rw-r--r--src/server/Model/Payment.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/server/Model/Payment.hs b/src/server/Model/Payment.hs
index db1f36f..ce8c5a1 100644
--- a/src/server/Model/Payment.hs
+++ b/src/server/Model/Payment.hs
@@ -23,12 +23,15 @@ import Model.Database
import qualified Model.Json.Payment as P
import qualified Model.Json.TotalPayment as TP
-getPayments :: Persist [P.Payment]
-getPayments = do
+getPayments :: Int -> Int -> Persist [P.Payment]
+getPayments page perPage = do
xs <- select $
from $ \(payment `InnerJoin` user) -> do
on (payment ^. PaymentUserId E.==. user ^. UserId)
where_ (isNothing (payment ^. PaymentDeletedAt))
+ orderBy [desc (payment ^. PaymentCreation)]
+ limit . fromIntegral $ perPage
+ offset . fromIntegral $ (page - 1) * perPage
return (payment, user)
return (map getJsonPayment xs)