mrfakename commited on
Commit
67d05e3
1 Parent(s): 9983762

more robust logs

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -66,6 +66,15 @@ def create_db_if_missing():
66
  timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
67
  );
68
  ''')
 
 
 
 
 
 
 
 
 
69
  cursor.execute('''
70
  CREATE TABLE IF NOT EXISTS spokentext (
71
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -366,12 +375,14 @@ def downvote_model(model, uname):
366
  def a_is_better(model1, model2, userid):
367
  userid = mkuuid(userid)
368
  if model1 and model2:
 
369
  upvote_model(model1, str(userid))
370
  downvote_model(model2, str(userid))
371
  return reload(model1, model2, userid, chose_a=True)
372
  def b_is_better(model1, model2, userid):
373
  userid = mkuuid(userid)
374
  if model1 and model2:
 
375
  upvote_model(model2, str(userid))
376
  downvote_model(model1, str(userid))
377
  return reload(model1, model2, userid, chose_b=True)
 
66
  timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
67
  );
68
  ''')
69
+ cursor.execute('''
70
+ CREATE TABLE IF NOT EXISTS votelog (
71
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
72
+ username TEXT,
73
+ chosen TEXT,
74
+ rejected TEXT,
75
+ timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
76
+ );
77
+ ''')
78
  cursor.execute('''
79
  CREATE TABLE IF NOT EXISTS spokentext (
80
  id INTEGER PRIMARY KEY AUTOINCREMENT,
 
375
  def a_is_better(model1, model2, userid):
376
  userid = mkuuid(userid)
377
  if model1 and model2:
378
+ cursor.execute('INSERT INTO votelog (username, chosen, rejected) VALUES (?, ?, ?)', (uname, model1, model2,))
379
  upvote_model(model1, str(userid))
380
  downvote_model(model2, str(userid))
381
  return reload(model1, model2, userid, chose_a=True)
382
  def b_is_better(model1, model2, userid):
383
  userid = mkuuid(userid)
384
  if model1 and model2:
385
+ cursor.execute('INSERT INTO votelog (username, chosen, rejected) VALUES (?, ?, ?)', (uname, model2, model1,))
386
  upvote_model(model2, str(userid))
387
  downvote_model(model1, str(userid))
388
  return reload(model1, model2, userid, chose_b=True)