uid = session["uid"]
return render_template('user.html',
name=db.get_name(uid),
- flavors=db.flavors(),
+ flavors=[_name for (_name, _ord) in db.flavors()],
count=db.coffee_count(uid, 0),
stamp=time.time()
)
fig = plt.figure(figsize=(4, 3))
ax = fig.add_subplot(111)
- list_flavor = sorted(db.flavors())
+ list_flavor = [_name for (_name, _ord) in sorted(db.flavors(), key=lambda x: x[1])]
l = [{} for i in range(len(list_flavor))]
for ll in l:
for d in unix_days:
def flavors():
conn, c = open_db()
- res = [row for row, in c.execute("select distinct name from flavors")]
+ res = list(c.execute("select distinct name, ord from flavors"))
close_db(conn)
return res
left join (select * from coffees
"""+query+""") c
on f.name=c.flavor group by f.name
+ order by f.ord asc
""", variables))
close_db(conn)
);
create table if not exists flavors (
- name varchar(255) primary key not null
+ name varchar(255) primary key not null,
+ ord integer not null default 999
);
insert or ignore into flavors values
- ("espresso"),
- ("espresso lungo"),
- ("cappuccino"),
- ("latte macchiato")
+ ("espresso", 2),
+ ("espresso lungo", 3),
+ ("cappuccino", 1),
+ ("latte macchiato", 4),
+ ("Club-Mate 0,5 l", 5),
+ ("Club-Mate 0,33 l", 6)
;
create table if not exists coffees (