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