From c115e31f342ff8ad731d78c28bda02620ce5a987 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Wed, 24 Feb 2021 06:55:46 +0100 Subject: [PATCH] Add logging progress in a simple script --- app/upgrade-to-0-2.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/upgrade-to-0-2.hs b/app/upgrade-to-0-2.hs index b58a431..e137ff7 100644 --- a/app/upgrade-to-0-2.hs +++ b/app/upgrade-to-0-2.hs @@ -42,16 +42,19 @@ process dbName = do return (variant, submission, out, test) Prelude.putStrLn "Adding evaluations…" - _ <- mapM (processVariant dbName) variants + let total = length variants + putStrLn $ "TOTAL " ++ (show total) + _ <- mapM (\(v, ix) -> processVariant total ix dbName v) $ zip variants [1..] putStrLn "DELETING" runOnDb dbName $ deleteWhere [EvaluationVersion ==. Nothing] return () -processVariant :: String -> (Entity Variant, Entity Submission, Entity Out, Entity Test) -> IO () -processVariant dbName (variant, Entity _ submission, Entity _ out, Entity testId _) = do +processVariant :: Int -> Int -> String -> (Entity Variant, Entity Submission, Entity Out, Entity Test) -> IO () +processVariant total ix dbName (variant, Entity _ submission, Entity _ out, Entity testId _) = do Prelude.putStrLn (show $ entityKey variant) + Prelude.putStrLn ((show ix) ++ "/" ++ (show total)) evaluations <- runOnDb dbName $ E.select $ E.from $ \evaluation -> do