diff options
author | Joris | 2019-10-27 20:26:29 +0100 |
---|---|---|
committer | Joris | 2019-10-27 20:26:29 +0100 |
commit | b97ad942495352c3fc1e0c820cfba82a9693ac7a (patch) | |
tree | f554831888929e2eff5e1fe478f92758637d37cf /server/src/Controller | |
parent | 8ef4d96644bce59bbb736af6359e644743e5610a (diff) |
WIP Set up server side paging for incomes
Diffstat (limited to 'server/src/Controller')
-rw-r--r-- | server/src/Controller/Income.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/server/src/Controller/Income.hs b/server/src/Controller/Income.hs index 236e032..3272cbf 100644 --- a/server/src/Controller/Income.hs +++ b/server/src/Controller/Income.hs @@ -1,5 +1,6 @@ module Controller.Income ( list + , listv2 , create , edit , delete @@ -12,7 +13,7 @@ import Web.Scotty hiding (delete) import Common.Model (CreateIncomeForm (..), EditIncomeForm (..), IncomeId, - User (..)) + IncomesAndCount (..), User (..)) import qualified Controller.Helper as ControllerHelper import Model.CreateIncome (CreateIncome (..)) @@ -28,6 +29,16 @@ list = (liftIO . Query.run $ IncomePersistence.list) >>= json ) +listv2 :: Int -> Int -> ActionM () +listv2 page perPage = + Secure.loggedAction (\_ -> + (liftIO . Query.run $ do + count <- IncomePersistence.count + incomes <- IncomePersistence.listv2 page perPage + return $ IncomesAndCount incomes count + ) >>= json + ) + create :: CreateIncomeForm -> ActionM () create form = Secure.loggedAction (\user -> |