Added progress bar to database build, GH-54

This commit is contained in:
Krateng 2020-12-01 20:32:29 +01:00
parent e1c9d525f5
commit 74dc54862e
2 changed files with 9 additions and 2 deletions

View File

@ -18,6 +18,7 @@ from doreah import tsv
from doreah import settings
from doreah.caching import Cache, DeepCache
from doreah.auth import authenticated_api, authenticated_api_with_alternate
from doreah.io import ProgressBar
try:
from doreah.persistence import DiskDict
except: pass
@ -767,6 +768,9 @@ def build_db():
# parse files
db = tsv.parse_all(datadir("scrobbles"),"int","string","string",comments=False)
scrobblenum = len(db)
log(f"Found {scrobblenum} scrobbles...")
pbar = ProgressBar(max=scrobblenum,prefix="Loading scrobbles")
#db = parseAllTSV("scrobbles","int","string","string",escape=False)
for sc in db:
artists = sc[1].split("")
@ -774,7 +778,10 @@ def build_db():
time = sc[0]
readScrobble(artists,title,time)
pbar.progress()
pbar.done()
log("Database loaded, optimizing...")
# optimize database
SCROBBLES.sort(key = lambda tup: tup[1])

View File

@ -590,10 +590,10 @@ def delimit_desc_p(d):
def delimit_desc(step="month",stepn=1,trail=1):
txt = ""
if stepn is not 1: txt += str(stepn) + "-"
if stepn != 1: txt += str(stepn) + "-"
txt += {"year":"Yearly","month":"Monthly","week":"Weekly","day":"Daily"}[step.lower()]
if trail is math.inf: txt += " Cumulative"
elif trail is not 1: txt += " Trailing" #we don't need all the info in the title
elif trail != 1: txt += " Trailing" #we don't need all the info in the title
return txt