aboutsummaryrefslogtreecommitdiff
path: root/src/executable
diff options
context:
space:
mode:
Diffstat (limited to 'src/executable')
-rw-r--r--src/executable/haskell/Service/AdListener.hs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/executable/haskell/Service/AdListener.hs b/src/executable/haskell/Service/AdListener.hs
index 5b4d634..9a9fc3d 100644
--- a/src/executable/haskell/Service/AdListener.hs
+++ b/src/executable/haskell/Service/AdListener.hs
@@ -21,8 +21,7 @@ import qualified View.Ad as Ad
start :: Conf -> Session -> IO ()
start conf session = do
- -- ads <- fetchAds conf session
- let ads = []
+ ads <- fetchAds conf session
let newURLs = map Ad.url ads
T.putStrLn "Listening to new ads…"
sleepUntilReady conf
@@ -48,13 +47,20 @@ fetchAds conf session = do
leboncoinAds <- FetchAd.leboncoin session (Conf.leboncoinUrls conf)
ouestFranceAds <- FetchAd.ouestFrance session (Conf.ouestFranceUrls conf)
seLogerAds <- FetchAd.seLoger session (Conf.seLogerUrls conf)
- let results = leboncoinAds ++ ouestFranceAds ++ seLogerAds
+ let ads = leboncoinAds ++ ouestFranceAds ++ seLogerAds
+ logFetchAds ads
+ return ads
+
+logFetchAds :: [Ad] -> IO ()
+logFetchAds ads = do
+ now <- TimeUtils.getCurrentFormattedTime
T.putStrLn . T.concat $
- [ "Parsed "
- , T.pack . show $ length results
- , " results"
+ [ "At "
+ , now
+ , ": fetched "
+ , T.pack . show $ length ads
+ , " ads"
]
- return results
sendMail :: Conf -> [Ad] -> IO ()
sendMail conf ads =
@@ -73,7 +79,6 @@ sleepUntilReady conf = do
Nothing -> do
duration <- TimeUtils.addNoise (Conf.listenInterval conf) (Conf.listenIntervalNoise conf)
- putStrLn . show $ duration
sleepSeconds duration
where
sleepSeconds =