fix percentage reporting semantics

This wasn't actually (much) broken, but we got burnt because percent
should mean [0, 100], not [0, 1].
This commit is contained in:
ducklet 2021-07-11 18:51:05 +02:00
parent cc0ba96a9e
commit 5ad4946f5b

View file

@ -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",