diff options
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 |