diff options
author | Joris | 2019-09-09 20:03:00 +0200 |
---|---|---|
committer | Joris | 2019-09-09 20:03:00 +0200 |
commit | 3e2c3f014bce0a82ac8708925806be05412898f9 (patch) | |
tree | cb15639f13fd0bbdb8335823c0199b0036c0b6f7 /src | |
parent | 91419f240b788339c202e0d35ef1df3cae64216b (diff) |
Log fetch ads time
Diffstat (limited to 'src')
-rw-r--r-- | src/executable/haskell/Service/AdListener.hs | 21 |
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 = |