blob: 203c4e8b6440061f6afaf532b0ff56e457da67f8 (
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
|
module Job.WeeklyReport
( weeklyReport
) where
import Data.Time.Clock (UTCTime, getCurrentTime)
import Conf (Conf)
import qualified Model.Query as Query
import qualified Persistence.Income as IncomePersistence
import qualified Persistence.Payment as PaymentPersistence
import qualified Persistence.User as UserPersistence
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 $
(,,) <$> PaymentPersistence.listPunctual <*> IncomePersistence.list <*> UserPersistence.list
_ <- SendMail.sendMail conf (WeeklyReport.mail conf users payments incomes lastExecution now)
return ()
return now
|