aboutsummaryrefslogtreecommitdiff
path: root/src/executable/haskell/Service
diff options
context:
space:
mode:
authorJoris2019-09-09 20:03:00 +0200
committerJoris2019-09-09 20:03:00 +0200
commit3e2c3f014bce0a82ac8708925806be05412898f9 (patch)
treecb15639f13fd0bbdb8335823c0199b0036c0b6f7 /src/executable/haskell/Service
parent91419f240b788339c202e0d35ef1df3cae64216b (diff)
Log fetch ads time
Diffstat (limited to 'src/executable/haskell/Service')
-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 =