From 5ad4946f5b1cb100a6e17978b690b0fcc09472e6 Mon Sep 17 00:00:00 2001 From: ducklet Date: Sun, 11 Jul 2021 18:51:05 +0200 Subject: [PATCH] fix percentage reporting semantics This wasn't actually (much) broken, but we got burnt because percent should mean [0, 100], not [0, 1]. --- unwind/imdb_import.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/unwind/imdb_import.py b/unwind/imdb_import.py index 57d21a3..fcc76eb 100644 --- a/unwind/imdb_import.py +++ b/unwind/imdb_import.py @@ -186,16 +186,17 @@ async def import_from_file(*, basics_path: Path, ratings_path: Path): log.info("💾 Importing movies ...") total = count_lines(basics_path) assert total != 0 - perc = 0.0 - perc_step = 0.001 + perc_next_report = 0.0 + perc_step = 0.1 chunk = [] for i, m in enumerate(read_basics(basics_path)): - if i / total > perc: - log.info("⏳ Imported %s%%", round(perc * 100, 1)) - perc += perc_step + perc = 100 * i / total + if perc >= perc_next_report: + log.info("⏳ Imported %s%%", round(perc, 1)) + perc_next_report += perc_step if m.media_type not in { "Movie",