close_db(conn)
return res
+
def coffee_history(uid=None):
conn, c = open_db()
if uid is None:
res = list(c.execute("""
- select strftime('%d', ds.d),count(c.time) from
+ select strftime('%d', 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
+ on d = date(c.time) group by d, c.flavor
"""))
else:
res = list(c.execute(
"""
- select strftime('%d', ds.d),count(c.time) from
+ select strftime('%d', ds.d),count(c.flavor),c.flavor from
(select num,date('now',-num || ' days') as d from days) ds
left join
- (select time from coffees where id = ? ) c
- on d = date(c.time) group by d
+ (select time,flavor from coffees where id = ?) c
+ on d = date(c.time) group by d, c.flavor
"""
, (uid,)))