aboutsummaryrefslogtreecommitdiff
path: root/server/src/Controller/Statistics.hs
blob: 500c93cb0a2c71f29124f4283a742824d89ca1b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Controller.Statistics
  ( paymentsAndIncomes
  ) where

import           Control.Monad.IO.Class (liftIO)
import           Web.Scotty             (ActionM)
import qualified Web.Scotty             as S

import qualified Model.Query            as Query
import qualified Persistence.Income     as IncomePersistence
import qualified Persistence.Payment    as PaymentPersistence
import qualified Secure
import qualified Statistics

paymentsAndIncomes :: ActionM ()
paymentsAndIncomes =
  Secure.loggedAction (\_ -> do
    payments <- liftIO $ Query.run PaymentPersistence.listAllPunctual
    incomes <- liftIO $ Query.run IncomePersistence.listAll
    S.json (Statistics.paymentsAndIncomes payments incomes)
  )