Make doIndex a loop
This commit is contained in:
parent
ac8e8a404a
commit
85bbc8516a
15
app/Main.hs
15
app/Main.hs
@ -114,12 +114,9 @@ doIndex :: Config -> DB -> ExceptT Error IO ()
|
|||||||
doIndex cfg db =
|
doIndex cfg db =
|
||||||
catchE
|
catchE
|
||||||
( DB.withTransaction db $ \conn -> do
|
( DB.withTransaction db $ \conn -> do
|
||||||
dayThen <- getTodayWithOffset (-100) 0
|
forM_ [0, 1, 2] $ \i -> do
|
||||||
indexDay cfg dayThen conn
|
dayThen <- getTodayWithOffset (-100) i
|
||||||
dayThen2 <- getTodayWithOffset (-100) 1
|
indexDay cfg dayThen conn
|
||||||
indexDay cfg dayThen2 conn
|
|
||||||
dayThen3 <- getTodayWithOffset (-100) 2
|
|
||||||
indexDay cfg dayThen3 conn
|
|
||||||
)
|
)
|
||||||
(Log.error . show)
|
(Log.error . show)
|
||||||
|
|
||||||
@ -144,6 +141,9 @@ runServer cfg db =
|
|||||||
(statusCode status)
|
(statusCode status)
|
||||||
(requestLine req)
|
(requestLine req)
|
||||||
|
|
||||||
|
onException mbReq ex = do
|
||||||
|
Log.error $ printf "unhandled exception%s: %s%s" (maybe "" ((" in " ++) . requestLine) mbReq) (show ex)
|
||||||
|
|
||||||
requestLine :: Request -> String
|
requestLine :: Request -> String
|
||||||
requestLine req =
|
requestLine req =
|
||||||
printf
|
printf
|
||||||
@ -151,9 +151,6 @@ runServer cfg db =
|
|||||||
(BS8.unpack $ requestMethod req)
|
(BS8.unpack $ requestMethod req)
|
||||||
(BS8.unpack $ rawPathInfo req <> rawQueryString req)
|
(BS8.unpack $ rawPathInfo req <> rawQueryString req)
|
||||||
|
|
||||||
onException mbReq ex = do
|
|
||||||
Log.error $ printf "unhandled exception%s: %s%s" (maybe "" ((" in " ++) . requestLine) mbReq) (show ex)
|
|
||||||
|
|
||||||
nt :: ExceptT Error IO a -> Handler a
|
nt :: ExceptT Error IO a -> Handler a
|
||||||
nt action = MkHandler $ do
|
nt action = MkHandler $ do
|
||||||
res <- runExceptT action
|
res <- runExceptT action
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user