diff options
author | Joris | 2016-11-13 00:49:32 +0100 |
---|---|---|
committer | Joris | 2016-11-13 00:49:32 +0100 |
commit | 86a96decdb8892b10c5314eb916ef15a64204450 (patch) | |
tree | 6f41742d0466f77948680964188144fbff036902 /src/server/Model/Payment.hs | |
parent | bf6a0a0b32a7efb88f75c2e89b84d6907aeb10bc (diff) |
Send weekly activity at start of week about previous week
Diffstat (limited to 'src/server/Model/Payment.hs')
-rw-r--r-- | src/server/Model/Payment.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/server/Model/Payment.hs b/src/server/Model/Payment.hs index 0d5e188..ac6cf0a 100644 --- a/src/server/Model/Payment.hs +++ b/src/server/Model/Payment.hs @@ -6,9 +6,11 @@ module Model.Payment , create , editOwn , deleteOwn + , modifiedDuring ) where import Data.Text (Text) +import Data.Time (UTCTime) import Data.Time.Clock (getCurrentTime) import Data.Time.Calendar (Day) @@ -86,3 +88,12 @@ deleteOwn userId paymentId = do return False Nothing -> return False + +modifiedDuring :: UTCTime -> UTCTime -> Persist [Payment] +modifiedDuring start end = + map entityVal <$> selectList + ( [PaymentFrequency ==. Punctual, PaymentCreatedAt >=. start, PaymentCreatedAt <. end] + ||. [PaymentFrequency ==. Punctual, PaymentEditedAt >=. Just start, PaymentEditedAt <. Just end] + ||. [PaymentFrequency ==. Punctual, PaymentDeletedAt >=. Just start, PaymentDeletedAt <. Just end] + ) + [] |