aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model
diff options
context:
space:
mode:
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)