IMDb import: fix progress reporting
Because we calculated the percentage based on the number of lines we need to yield once per line, otherwise the count is off.
This commit is contained in:
parent
e84a6bc865
commit
69643455a6
1 changed files with 6 additions and 1 deletions
|
|
@ -177,13 +177,14 @@ def read_ratings_as_mapping(path: Path):
|
|||
return {r[0]: (round(100 * (float(r[1]) - 1) / 9), int(r[2])) for r in rows}
|
||||
|
||||
|
||||
def read_basics(path: Path):
|
||||
def read_basics(path: Path) -> Generator[Movie | None, None, None]:
|
||||
mtime = gz_mtime(path)
|
||||
rows = read_imdb_tsv(path, BasicRow)
|
||||
|
||||
for row in rows:
|
||||
if row.startYear is None:
|
||||
log.debug("Skipping movie, missing year: %s", row)
|
||||
yield None
|
||||
continue
|
||||
|
||||
m = row.as_movie()
|
||||
|
|
@ -210,6 +211,9 @@ async def import_from_file(*, basics_path: Path, ratings_path: Path):
|
|||
log.info("⏳ Imported %s%%", round(perc, 1))
|
||||
perc_next_report += perc_step
|
||||
|
||||
if m is None:
|
||||
continue
|
||||
|
||||
if m.media_type not in {
|
||||
"Movie",
|
||||
"Short",
|
||||
|
|
@ -234,6 +238,7 @@ async def import_from_file(*, basics_path: Path, ratings_path: Path):
|
|||
await add_or_update_many_movies(chunk)
|
||||
chunk = []
|
||||
|
||||
log.info("👍 Imported 100%")
|
||||
await db.set_import_progress(100)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue