diff options
author | Joris | 2015-09-03 23:32:39 +0200 |
---|---|---|
committer | Joris | 2015-09-03 23:32:39 +0200 |
commit | 889df8caf04de5f10a9e623bab3e502e9573159d (patch) | |
tree | d8c3dff55ffd38914543213e544c55e346e1f13e /src/server/Model/Payment.hs | |
parent | ebd304d97b612d0ac4ea276b1c29ba8ecc0b7998 (diff) |
Give the payments count to the client
Diffstat (limited to 'src/server/Model/Payment.hs')
-rw-r--r-- | src/server/Model/Payment.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/server/Model/Payment.hs b/src/server/Model/Payment.hs index 300f6b8..db1f36f 100644 --- a/src/server/Model/Payment.hs +++ b/src/server/Model/Payment.hs @@ -4,6 +4,7 @@ module Model.Payment , paymentKeyToText , deleteOwnPayment , getTotalPayments + , getPaymentsCount ) where import Data.Text (Text) @@ -82,3 +83,11 @@ getTotalPayment (_, Nothing) = Nothing unValueTuple :: (Value a, Value b) -> (a, b) unValueTuple (Value a, Value b) = (a, b) + +getPaymentsCount :: Persist Int +getPaymentsCount = + unValue . head <$> + (select $ + from $ \payment -> do + where_ (isNothing (payment ^. PaymentDeletedAt)) + return countRows) :: Persist Int |