]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/blobdiff - coffee_db.py
Fix the data log in offline server mode
[coffee/coffee-flask.git] / coffee_db.py
index 6207b29d3764c781e0cfdcfb63c448d2bbf1961a..a838746dfaf9ba9e77f1ff5fc6f8634c9dab375a 100644 (file)
@@ -90,24 +90,25 @@ def coffee_flavors(uid=None):
     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,)))