aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorJoris2015-09-13 19:18:42 +0200
committerJoris2015-09-13 19:18:47 +0200
commit6b3c243031e941b58fc5df0d0d00ec8cad62d4e0 (patch)
tree44fedc9b70114b0fe94cffde30d157e5f72d2def /src/server
parentf951d9886ed7bb70d06162c584b357670864d310 (diff)
Removing useless user join on total payment query
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Model/Payment.hs5
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