Skip to content

Commit

Permalink
Add rich based progess display to sales import
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Nov 3, 2024
1 parent 2adc908 commit 5c0ba03
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions discodos/ctrl/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from abc import ABC
# import pprint as p
from time import time

import discogs_client.exceptions as errors
from rich.progress import (BarColumn, MofNCompleteColumn, Progress,
TaskProgressColumn, )

from discodos.ctrl.common import ControlCommon
from discodos.model_brainz import Brainz
Expand Down Expand Up @@ -797,8 +798,21 @@ def import_sales_inventory(self):
"""Import sales inventory"""
start_time = time()
self.cli.exit_if_offline(self.collection.ONLINE)
self.cli.p("Importing Discogs sales inventory into DiscoBASE")
for item in self.collection.me.inventory:
# print(item.release.id, item.id, item.release.artists[0], item.release.title)
self.collection.create_sales_entry(item.release.id, item.id)
self.cli.duration_stats(start_time, 'Discogs sales inventory import')
self.cli.p("Importing Discogs sales inventory into DiscoBASE...")
custom_progress = Progress(
MofNCompleteColumn(),
BarColumn(),
TaskProgressColumn(),
)
total_items = len(self.collection.me.inventory)

with custom_progress:
task = custom_progress.add_task(
"[cyan] Status: ",
total=total_items,
)
for item in self.collection.me.inventory:
self.collection.create_sales_entry(item.release.id, item.id)
custom_progress.update(task, advance=1)

self.cli.duration_stats(start_time, 'Inventory import')

0 comments on commit 5c0ba03

Please sign in to comment.