diff options
author | Joris | 2015-09-04 09:52:20 +0200 |
---|---|---|
committer | Joris | 2015-09-04 09:52:20 +0200 |
commit | c1f44a5890fbb26faf6f17c676662ea1bd495f2e (patch) | |
tree | f158bdef5bd985a9b11d46d12878d566268cf6cc /src/server/Model | |
parent | 889df8caf04de5f10a9e623bab3e502e9573159d (diff) |
Adding paging (need some fixes)
Diffstat (limited to 'src/server/Model')
-rw-r--r-- | src/server/Model/Payment.hs | 7 |
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) |