else:
hist = db.coffee_history()
if hist == []:
- days = tuple()
+ unix_days = tuple()
counts = tuple()
flavors = tuple()
else:
- days, counts, flavors = zip(*hist)
+ unix_days, counts, flavors = zip(*hist)
fig = plt.figure(figsize=(4, 3))
ax = fig.add_subplot(111)
list_flavor = sorted(db.flavors())
l = [{} for i in range(len(list_flavor))]
for ll in l:
- for d in days:
+ for d in unix_days:
ll[d] = 0
- for(d, c, f) in zip(days, counts, flavors):
+ for(d, c, f) in zip(unix_days, counts, flavors):
if f is None:
continue
what_f = 0
ax.bar(range(len(x)), y, bottom=z)
z = [sum(i) for i in zip(y, z)]
- days = set(days)
+ unix_days = set(unix_days)
xdays = [i.strftime("%a") for i in [
date.today() - timedelta(j - 1) for j in
- range(len(days), 0, -1)]]
+ range(len(unix_days), 0, -1)]]
xdays[-1] = "TDY"
xdays[-2] = "YDA"
- ax.set_xticks(range(len(days)))
+ ax.set_xticks(range(len(unix_days)))
ax.set_xticklabels(xdays)
ax.set_title("Your week")
ax.yaxis.set_major_locator(MaxNLocator(integer=True))
if uid is None:
res = list(c.execute("""
- select strftime('%d', ds.d),count(c.flavor),c.flavor from
+ select strftime('%s', ds.d),count(c.flavor),c.flavor from
(select num,date('now',-num || ' days') as d from days) ds
left join coffees c
on d = date(c.time) group by d, c.flavor
else:
res = list(c.execute(
"""
- select strftime('%d', ds.d),count(c.flavor),c.flavor from
+ select strftime('%s', ds.d),count(c.flavor),c.flavor from
(select num,date('now',-num || ' days') as d from days) ds
left join
(select time,flavor from coffees where id = ?) c