Commit 3e2c3f01 authored by Joris's avatar Joris

Log fetch ads time

parent 91419f24
......@@ -36,5 +36,6 @@ See [application.conf](application.conf).
## Ideas
- add logging system
- add sqlite DB, to get back to previous state if shut down, it also permits to
see what has already been seen.
......@@ -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 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment