diff options
author | Joris | 2015-09-13 19:18:42 +0200 |
---|---|---|
committer | Joris | 2015-09-13 19:18:47 +0200 |
commit | 6b3c243031e941b58fc5df0d0d00ec8cad62d4e0 (patch) | |
tree | 44fedc9b70114b0fe94cffde30d157e5f72d2def | |
parent | f951d9886ed7bb70d06162c584b357670864d310 (diff) |
Removing useless user join on total payment query
-rw-r--r-- | src/server/Model/Payment.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/server/Model/Payment.hs b/src/server/Model/Payment.hs index 0db2f08..469f0d3 100644 --- a/src/server/Model/Payment.hs +++ b/src/server/Model/Payment.hs @@ -82,12 +82,11 @@ deleteOwnPayment user paymentId = do getTotalPayments :: Persist [TP.TotalPayment] getTotalPayments = do values <- select $ - from $ \(payment `InnerJoin` user) -> do - on (payment ^. PaymentUserId E.==. user ^. UserId) + from $ \payment -> do where_ (isNothing (payment ^. PaymentDeletedAt)) where_ (payment ^. PaymentFrequency E.==. val Punctual) groupBy (payment ^. PaymentUserId) - return (user ^. UserId, sum_ (payment ^. PaymentCost)) + return (payment ^. PaymentUserId, sum_ (payment ^. PaymentCost)) return $ catMaybes . map (getTotalPayment . unValueTuple) $ values getTotalPayment :: (UserId, Maybe Int) -> Maybe TP.TotalPayment |