Skip to content

Commit

Permalink
Add current index and total of items to migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Feb 5, 2025
1 parent 7ed016e commit fb15342
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/btrixcloud/migrations/migration_0042_page_filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@ async def migrate_up(self):

if self.page_ops is None:
print(
"Unable to add filename to pages, missing page_ops",
"Unable to add filename and other fields to pages, missing page_ops",
flush=True,
)
return

crawl_ids_to_update = await pages_mdb.distinct("crawl_id", {"filename": None})

crawl_count = len(crawl_ids_to_update)
current_index = 1

for crawl_id in crawl_ids_to_update:
print(f"Migrating archived item {current_index}/{crawl_count}", flush=True)
try:
await self.page_ops.add_crawl_wacz_filename_to_pages(crawl_id)
# pylint: disable=broad-exception-caught
except Exception as err:
print(
f"Error adding filename to pages in item {crawl_id}: {err}",
f"Error adding filename and other fields to pages in item {crawl_id}: {err}",
flush=True,
)
current_index += 1

0 comments on commit fb15342

Please sign in to comment.