blob: 5737c7571b656c189e4fac758bf822a106241cbd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
module Job.WeeklyReport
( weeklyReport
) where
import Data.Time.Clock (UTCTime, getCurrentTime)
import Conf (Conf)
import qualified Model.Income as Income
import qualified Model.Payment as Payment
import qualified Model.Query as Query
import qualified Model.User as User
import qualified SendMail
import qualified View.Mail.WeeklyReport as WeeklyReport
weeklyReport :: Conf -> Maybe UTCTime -> IO UTCTime
weeklyReport conf mbLastExecution = do
now <- getCurrentTime
case mbLastExecution of
Nothing -> return ()
Just lastExecution -> do
(payments, incomes, users) <- Query.run $
(,,) <$>
Payment.modifiedDuring lastExecution now <*>
Income.modifiedDuring lastExecution now <*>
User.list
_ <- SendMail.sendMail (WeeklyReport.mail conf users payments incomes lastExecution now)
return ()
return now
|